[][src]Struct event::EventQueue

pub struct EventQueue<R, E = IOError> {
    pub file: File,
    // some fields omitted
}

Fields

file: File

The file to read events from

Methods

impl<R, E> EventQueue<R, E> where
    E: From<IOError>, 
[src]

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]

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]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.