Struct Base

Source
pub struct Base { /* private fields */ }
Expand description

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

Implementations§

Source§

impl Base

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

Source

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

Creates a new instance of Base.

Source

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

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.

Source

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

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.

Source

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

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

Source

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

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

Source

pub fn loopbreak(&self) -> i32

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

Source

pub fn loopcontinue(&self) -> i32

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

Source

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>>

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

Source

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

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

Source

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

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

Source§

impl Base

Source

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

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.

Source

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

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>.

Source§

impl Base

Source

pub fn turn(&self) -> ExitReason

Turns the libevent base once.

Source

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

Turns the libevent base until exit or timeout duration reached.

Source

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

Turns the libevent base until next active event.

Source

pub fn run(&self) -> ExitReason

Turns the libevent base until exit.

Trait Implementations§

Auto Trait Implementations§

§

impl Freeze for Base

§

impl RefUnwindSafe for Base

§

impl !Sync for Base

§

impl Unpin for Base

§

impl UnwindSafe for Base

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.