Enum dbus::ffidisp::WatchEvent
source · [−]#[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
sourceimpl WatchEvent
impl WatchEvent
sourcepub fn from_revents(revents: c_short) -> c_uint
pub fn from_revents(revents: c_short) -> c_uint
After running poll, this transforms the revents into a parameter you can send into Connection::watch_handle
Trait Implementations
sourceimpl Clone for WatchEvent
impl Clone for WatchEvent
sourcefn clone(&self) -> WatchEvent
fn clone(&self) -> WatchEvent
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for WatchEvent
impl Debug for WatchEvent
sourceimpl PartialEq<WatchEvent> for WatchEvent
impl PartialEq<WatchEvent> for WatchEvent
sourcefn eq(&self, other: &WatchEvent) -> bool
fn eq(&self, other: &WatchEvent) -> bool
impl Copy for WatchEvent
impl StructuralPartialEq for WatchEvent
Auto Trait Implementations
impl RefUnwindSafe for WatchEvent
impl Send for WatchEvent
impl Sync for WatchEvent
impl Unpin for WatchEvent
impl UnwindSafe for WatchEvent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more