I came across this library to support epoll
in rust but I'm not sure how to properly use the epoll:wait
function:
let mut events = [Event; 10];
rc = epoll::wait(self.vfio_epoll_fd, timeout, &mut events)?;
Would be nice if someone could provide me with some examples to get started :) Thanks in advance for your support.
I get the following error when compiling the above code:
error[E0423]: expected value, found struct `Event`
--> src/interrupts.rs:132:27
|
132 | let mut events = [Event; 10];
| ^^^^^ did you mean `Event { /* fields */ }`?
Event structure looks like this:
pub struct Event {
pub events: Events,
pub data: u64,
}
The problem is I don't know what Events
as it is a bitflag.
Since events
is an output parameter for epoll::wait
you can put anything in there, but you need to put a valid value. A sensible default would be an empty event set:
let mut events = [Event::empty(); 10];
Events
is a struct generated by the bitflags
macro, so looking at the source code won't help much in understanding how to use it, but luckily bitflags
also generates quite comprehensive documentation for the generated structs.