[−][src]Enum dbus::WatchEvent
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
Readable
The fd is readable
Writable
The fd is writable
Error
An error occured on the fd
Hangup
The fd received a hangup.
Methods
impl WatchEvent
[src]
pub fn from_revents(revents: c_short) -> c_uint
[src]
After running poll, this transforms the revents into a parameter you can send into Connection::watch_handle
Trait Implementations
impl PartialEq<WatchEvent> for WatchEvent
[src]
fn eq(&self, other: &WatchEvent) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Clone for WatchEvent
[src]
fn clone(&self) -> WatchEvent
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for WatchEvent
[src]
impl Debug for WatchEvent
[src]
Auto Trait Implementations
impl Unpin for WatchEvent
impl Sync for WatchEvent
impl Send for WatchEvent
impl RefUnwindSafe for WatchEvent
impl UnwindSafe for WatchEvent
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,