#[repr(C)]
pub enum WatchEvent {
    Readable,
    Writable,
    Error,
    Hangup,
}
Expand description

A file descriptor to watch for incoming events (for async I/O).

Example

extern crate libc;
extern crate dbus;
fn main() {
    use dbus::ffidisp::{Connection, BusType, WatchEvent};
    let c = Connection::get_private(BusType::Session).unwrap();

    // Get a list of fds to poll for
    let mut fds: Vec<_> = c.watch_fds().iter().map(|w| w.to_pollfd()).collect();

    // Poll them with a 1 s timeout
    let r = unsafe { libc::poll(fds.as_mut_ptr(), fds.len() as libc::c_ulong, 1000) };
    assert!(r >= 0);

    // And handle incoming events
    for pfd in fds.iter().filter(|pfd| pfd.revents != 0) {
        for item in c.watch_handle(pfd.fd, WatchEvent::from_revents(pfd.revents)) {
            // Handle item
            println!("Received ConnectionItem: {:?}", item);
        }
    }
}

The enum is here for backwards compatibility mostly.

It should really be bitflags instead.

Variants

Readable

The fd is readable

Writable

The fd is writable

Error

An error occured on the fd

Hangup

The fd received a hangup.

Implementations

After running poll, this transforms the revents into a parameter you can send into Connection::watch_handle

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.