[−][src]Struct event::EventQueue
Fields
file: File
The file to read events from
Methods
impl<R, E> EventQueue<R, E> where
E: From<IOError>,
[src]
E: From<IOError>,
pub fn new() -> IOResult<EventQueue<R, E>>
[src]
Create a new event queue
pub fn set_default_callback<F>(&mut self, callback: F) where
F: FnMut(Event) -> Result<Option<R>, E> + 'static,
[src]
F: FnMut(Event) -> Result<Option<R>, E> + 'static,
Set the default callback to be called if an event is produced
by a FD not registered with add
.
pub fn add<F: FnMut(Event) -> Result<Option<R>, E> + 'static>(
&mut self,
fd: RawFd,
callback: F
) -> IOResult<usize>
[src]
&mut self,
fd: RawFd,
callback: F
) -> IOResult<usize>
Add a file to the event queue, calling a callback when an event occurs. Returns the event id it got, which can be used to remove or trigger this event.
The callback returns Ok(None) if it wishes to continue the event loop, or Ok(Some(R)) to break the event loop and return the value. Err can be used to allow the callback to return an error, and break the event loop.
pub fn remove(
&mut self,
id: usize
) -> IOResult<Option<Box<dyn FnMut(Event) -> Result<Option<R>, E>>>>
[src]
&mut self,
id: usize
) -> IOResult<Option<Box<dyn FnMut(Event) -> Result<Option<R>, E>>>>
Remove a file from the event queue, returning its callback if found
pub fn trigger(&mut self, id: usize, event: Event) -> Result<Option<R>, E>
[src]
Send an event to a descriptor callback
pub fn trigger_all(&mut self, event: Event) -> Result<Vec<R>, E>
[src]
Send an event to all descriptor callbacks, useful for cleaning out buffers after init
pub fn run(&mut self) -> Result<R, E>
[src]
Process the event queue until a callback returns Some(R)
Auto Trait Implementations
impl<R, E = Error> !RefUnwindSafe for EventQueue<R, E>
impl<R, E = Error> !Send for EventQueue<R, E>
impl<R, E = Error> !Sync for EventQueue<R, E>
impl<R, E> Unpin for EventQueue<R, E>
impl<R, E = Error> !UnwindSafe for EventQueue<R, E>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for 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>,