Enum dbus::WatchEvent [] [src]

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

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

Example

extern crate libc;
extern crate dbus;
fn main() {
    use dbus::{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

The fd is readable

The fd is writable

An error occured on the fd

The fd received a hangup.

Methods

impl WatchEvent
[src]

[src]

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

Trait Implementations

impl Debug for WatchEvent
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for WatchEvent
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Copy for WatchEvent
[src]

impl Clone for WatchEvent
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more