Struct mesh::MpscReceiver
source · pub struct MpscReceiver<T> { /* private fields */ }
Expand description
Receiver type for mpsc_channel()
.
Implementations§
source§impl<T> MpscReceiver<T>where
T: MeshField,
impl<T> MpscReceiver<T>where
T: MeshField,
sourcepub fn upcast<U>(self) -> MpscReceiver<U>
pub fn upcast<U>(self) -> MpscReceiver<U>
Upcasts this receiver to one that can receive values whose encoding is a
superset of T
’s.
sourcepub fn force_downcast<U>(self) -> MpscReceiver<U>
pub fn force_downcast<U>(self) -> MpscReceiver<U>
Downcasts this receiver to one that can receive values whose encoding is
a subset of T
’s.
Although this is memory safe, it can cause decoding failures if the
associated sender sends values that don’t decode to U
.
source§impl<T> MpscReceiver<T>where
T: 'static + Send,
impl<T> MpscReceiver<T>where
T: 'static + Send,
sourcepub fn new() -> MpscReceiver<T>
pub fn new() -> MpscReceiver<T>
Creates a new receiver with no senders.
Receives will fail with RecvError::Closed
until Self::sender
is
called.
sourcepub fn sender(&mut self) -> MpscSender<T>
pub fn sender(&mut self) -> MpscSender<T>
Creates a new sender for sending data to this receiver.
Note that this may transition the channel from the closed to open state.
sourcepub fn recv(&mut self) -> impl Future<Output = Result<T, RecvError>>
pub fn recv(&mut self) -> impl Future<Output = Result<T, RecvError>>
Consumes and returns the next message, waiting until one is available.
Returns immediately when the channel is closed or failed.
let (send, mut recv) = mpsc_channel();
send.send(5u32);
drop(send);
assert_eq!(recv.recv().await.unwrap(), 5);
assert!(matches!(recv.recv().await.unwrap_err(), RecvError::Closed));
Trait Implementations§
source§impl<T> Debug for MpscReceiver<T>
impl<T> Debug for MpscReceiver<T>
source§impl<T> Default for MpscReceiver<T>where
T: 'static + Send,
impl<T> Default for MpscReceiver<T>where
T: 'static + Send,
source§fn default() -> MpscReceiver<T>
fn default() -> MpscReceiver<T>
Returns the “default value” for a type. Read more
source§impl<T> DefaultEncoding for MpscReceiver<T>where
T: MeshField,
impl<T> DefaultEncoding for MpscReceiver<T>where
T: MeshField,
source§type Encoding = TableEncoder
type Encoding = TableEncoder
The encoding to use for the serialization. Read more
source§impl<T> FusedStream for MpscReceiver<T>where
T: 'static + Send,
impl<T> FusedStream for MpscReceiver<T>where
T: 'static + Send,
source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns
true
if the stream should no longer be polled.source§impl<T> Stream for MpscReceiver<T>where
T: 'static + Send,
impl<T> Stream for MpscReceiver<T>where
T: 'static + Send,
source§fn poll_next(
self: Pin<&mut MpscReceiver<T>>,
cx: &mut Context<'_>,
) -> Poll<Option<<MpscReceiver<T> as Stream>::Item>>
fn poll_next( self: Pin<&mut MpscReceiver<T>>, cx: &mut Context<'_>, ) -> Poll<Option<<MpscReceiver<T> as Stream>::Item>>
Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
None
if the stream is exhausted. Read moresource§impl<'encoding, T> StructDecodeMetadata<'encoding, Resource> for MpscReceiver<T>where
T: MeshField,
impl<'encoding, T> StructDecodeMetadata<'encoding, Resource> for MpscReceiver<T>where
T: MeshField,
source§const DECODERS: &'static [ErasedDecoderEntry] = _
const DECODERS: &'static [ErasedDecoderEntry] = _
The list of decoder vtables.
source§impl<T> StructEncodeMetadata<Resource> for MpscReceiver<T>where
T: MeshField,
impl<T> StructEncodeMetadata<Resource> for MpscReceiver<T>where
T: MeshField,
source§const ENCODERS: &'static [ErasedEncoderEntry] = _
const ENCODERS: &'static [ErasedEncoderEntry] = _
The list of encoder vtables.
source§impl<T> StructMetadata for MpscReceiver<T>where
T: MeshField,
impl<T> StructMetadata for MpscReceiver<T>where
T: MeshField,
impl<T, U> Downcast<MpscReceiver<U>> for MpscReceiver<T>where
T: Downcast<U>,
Auto Trait Implementations§
impl<T> Freeze for MpscReceiver<T>
impl<T> !RefUnwindSafe for MpscReceiver<T>
impl<T> Send for MpscReceiver<T>
impl<T> Sync for MpscReceiver<T>
impl<T> Unpin for MpscReceiver<T>
impl<T> !UnwindSafe for MpscReceiver<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> SerializeMessage for Twhere
T: MeshPayload,
impl<T> SerializeMessage for Twhere
T: MeshPayload,
source§fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
Computes the message size, as in
MessageEncode::compute_message_size
.source§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
Writes the message, as in
MessageEncode::write_message
.source§fn extract(self) -> <T as SerializeMessage>::Concrete
fn extract(self) -> <T as SerializeMessage>::Concrete
Extract the concrete message.