Handle

Struct Handle 

Source
pub struct Handle<M: Message> { /* private fields */ }
Expand description

Provides bidirectional communication with a reactor. If this is dropped the reactor stops.

Implementations§

Source§

impl<M: Message> Handle<M>

Source

pub fn send(&self, command: Command<M>) -> Result<()>

Sends a command to a reactor associated with this handle. If this produces an IO error, it means the reactor is irrecoverable and should be discarded. This method never blocks so it is appropriate for use in async contexts.

Source

pub fn receive_blocking(&self) -> Result<Event<M>>

Blocks until the reactor associated with this handle produces a message. If an IO error is produced, the reactor is irrecoverable and should be discarded. While this method is available in async contexts, it should not be used there. Use receiver() to get a raw handle on the receiver for use in async scenarios or where extra API surfaces are required.

Source

pub fn receiver(&self) -> &Receiver<Event<M>>

Exposes the receive portion of the handle. The receiver could be of a blocking or async variety, depending on which feature is active.

Source

pub fn shutdown(self) -> Result<JoinHandle<Result<()>>>

Shuts down the reactor and consumes the handle. No further commands can be sent afterward.

Source

pub fn panic(self) -> Result<()>

Causes the reactor to panic. For testing only. No further commands can be sent afterward.

Auto Trait Implementations§

§

impl<M> Freeze for Handle<M>

§

impl<M> !RefUnwindSafe for Handle<M>

§

impl<M> Send for Handle<M>

§

impl<M> Sync for Handle<M>

§

impl<M> Unpin for Handle<M>
where M: Unpin,

§

impl<M> !UnwindSafe for Handle<M>

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.