[][src]Struct libevent::Base

pub struct Base { /* fields omitted */ }

Wrapper for libevent's event_base which is responsible for executing associated events.

Implementations

impl Base[src]

The handle that abstracts over libevent's API in Rust.

pub fn new() -> Result<Self, Error>[src]

Creates a new instance of Base.

pub unsafe fn from_raw(base: NonNull<event_base>) -> Self[src]

Creates a new instance of Base using a raw, non-null event_base pointer.

Safety

This function expects a non-null pointer, and thus does no such checks internally. Thus the caller is responsible for checking the event_base validity.

pub unsafe fn as_raw(&self) -> NonNull<event_base>[src]

Exposes the raw, non-null event_base pointer.

Safety

This function returns a valid, non-null event_base pointer which by itself is safe. However, this function serves as an escape hatch to do unsafe things.

pub fn loop_(&self, flags: LoopFlags) -> ExitReason[src]

Wrapper for libevent's event_base_loop, which runs the event loop in a manner defined by the LoopFlags input.

pub fn loopexit(&self, timeout: Duration) -> i32[src]

Wrapper for libevent's event_base_loopexit, which tells the running event loop to exit after a specified Duration.

pub fn loopbreak(&self) -> i32[src]

Wrapper for libevent's event_base_loopbreak, which tells the running event loop to break immediately.

pub fn loopcontinue(&self) -> i32[src]

Wrapper for libevent's event_base_loopcontinue, which tells the running event loop to resume searching for active events.

pub fn event_new(
    &mut self,
    fd: Option<EvutilSocket>,
    flags: EventFlags,
    callback: extern "C" fn(_: EvutilSocket, _: EventCallbackFlags, _: EventCallbackCtx),
    callback_ctx: Option<EventCallbackCtx>
) -> Option<NonNull<event>>
[src]

Wrapper for libevent's event_new, which allocates and initializes a new event with the given parameters.

pub fn event_assign(
    &mut self,
    ev: NonNull<event>,
    fd: Option<EvutilSocket>,
    flags: EventFlags,
    callback: extern "C" fn(_: EvutilSocket, _: EventCallbackFlags, _: EventCallbackCtx),
    callback_ctx: Option<EventCallbackCtx>
) -> c_int
[src]

Wrapper for libevent's event_new, which initializes a pre-allocated event with the given parameters.

pub fn event_add(
    &self,
    event: NonNull<event>,
    timeout: Option<Duration>
) -> c_int
[src]

Wrapper for libevent's event_add, which activates an initialized event for a pre-defined Base and a given timeout interval.

impl Base[src]

pub fn spawn<T: Exec<Internal<T>, F>, F>(
    &mut self,
    ev: Event<Inactive<T>>,
    cb: F
) -> Result<()>
[src]

Activates a given inactive Event with no handle sharing.

Control of the event via the Event handle is relegated only from within the closure F, which means that no synchronization wrappers are required for operation.

pub fn spawn_local<T: Exec<LocalWeak<T>, F>, F>(
    &mut self,
    ev: Event<Inactive<T>>,
    cb: F
) -> Result<Event<Local<T>>>
[src]

Activates a given inactive Event with thread-local sharing.

Control of the event via the Event handle is shared between the closure F as well as the returned Event, which internally uses an Rc<RefCell>.

impl Base[src]

pub fn turn(&self) -> ExitReason[src]

Turns the libevent base once.

pub fn run_timeout(&self, timeout: Duration) -> ExitReason[src]

Turns the libevent base until exit or timeout duration reached.

pub fn run_until_event(&self, timeout: Option<Duration>) -> ExitReason[src]

Turns the libevent base until next active event.

pub fn run(&self) -> ExitReason[src]

Turns the libevent base until exit.

Trait Implementations

impl Send for Base[src]

Auto Trait Implementations

impl RefUnwindSafe for Base

impl !Sync for Base

impl Unpin for Base

impl UnwindSafe for Base

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.