calloop::channel

Struct Channel

source
pub struct Channel<T> { /* private fields */ }
Expand description

The receiving end of the channel

This is the event source to be inserted into your EventLoop.

Implementations§

source§

impl<T> Channel<T>

source

pub fn recv(&self) -> Result<T, RecvError>

Proxy for mpsc::Receiver::recv to manually poll events.

Note: Normally you would want to use the Channel by inserting it into an event loop instead. Use this for example to immediately dispatch pending events after creation.

source

pub fn try_recv(&self) -> Result<T, TryRecvError>

Proxy for mpsc::Receiver::try_recv to manually poll events.

Note: Normally you would want to use the Channel by inserting it into an event loop instead. Use this for example to immediately dispatch pending events after creation.

Trait Implementations§

source§

impl<T: Debug> Debug for Channel<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> EventSource for Channel<T>

source§

type Event = Event<T>

The type of events generated by your source.
source§

type Metadata = ()

Some metadata of your event source Read more
source§

type Ret = ()

The return type of the user callback Read more
source§

type Error = ChannelError

The error type returned from process_events() (not the user callback!).
source§

fn process_events<C>( &mut self, readiness: Readiness, token: Token, callback: C, ) -> Result<PostAction, Self::Error>
where C: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

Process any relevant events Read more
source§

fn register( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory, ) -> Result<()>

Register yourself to this poll instance Read more
source§

fn reregister( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory, ) -> Result<()>

Re-register your file descriptors Read more
source§

fn unregister(&mut self, poll: &mut Poll) -> Result<()>

Unregister your file descriptors Read more
source§

const NEEDS_EXTRA_LIFECYCLE_EVENTS: bool = false

Whether this source needs to be sent the EventSource::before_sleep and EventSource::before_handle_events notifications. These are opt-in because they require more expensive checks, and almost all sources will not need these notifications
source§

fn before_sleep(&mut self) -> Result<Option<(Readiness, Token)>>

Notification that a single poll is about to begin Read more
source§

fn before_handle_events(&mut self, events: EventIterator<'_>)

Notification that polling is complete, and EventSource::process_events will be called with the given events for this source. The iterator may be empty, which indicates that no events were generated for this source Read more
source§

impl<T: Send> Send for Channel<T>

Auto Trait Implementations§

§

impl<T> Freeze for Channel<T>

§

impl<T> !RefUnwindSafe for Channel<T>

§

impl<T> !Sync for Channel<T>

§

impl<T> Unpin for Channel<T>

§

impl<T> !UnwindSafe for Channel<T>

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more