]>
git.proxmox.com Git - proxmox-backup.git/blob - qemu-io/src/util.rs
1 //! Some types used by both our internal testing AioContext implementation as well as our
2 //! WithAioContext wrapper.
4 /// An Aio Callback. Qemu's AioContext actually uses a void function taking an opaque pointer.
5 /// For simplicity we stick to closures for now.
6 pub type AioCb
= std
::sync
::Arc
<dyn Fn() + Send
+ Sync
>;
8 /// This keeps track of our poll state (whether we wait to be notified for read or write
11 pub struct AioHandlerState
{
12 pub read
: Option
<AioCb
>,
13 pub write
: Option
<AioCb
>,
16 impl AioHandlerState
{
17 /// Get an mio::Ready with readable set if `read` is `Some`, and writable
18 /// set if `write` is `Some`.
19 pub fn mio_ready(&self) -> mio
::Ready
{
22 let mut ready
= Ready
::empty();
23 if self.read
.is_some() {
24 ready
|= Ready
::readable();
27 if self.write
.is_some() {
28 ready
|= Ready
::writable();
35 pub fn clear(&mut self) {