Struct mesh_channel::MpscReceiver
source · pub struct MpscReceiver<T> { /* private fields */ }
Expand description
Receiver type for mpsc_channel()
.
Implementations§
source§impl<T: MeshField> MpscReceiver<T>
impl<T: MeshField> MpscReceiver<T>
sourcepub fn upcast<U: MeshField>(self) -> MpscReceiver<U>where
Self: Upcast<MpscReceiver<U>>,
pub fn upcast<U: MeshField>(self) -> MpscReceiver<U>where
Self: Upcast<MpscReceiver<U>>,
Upcasts this receiver to one that can receive values whose encoding is a
superset of T
’s.
sourcepub fn force_downcast<U: MeshField>(self) -> MpscReceiver<U>where
MpscReceiver<U>: Upcast<Self>,
pub fn force_downcast<U: MeshField>(self) -> MpscReceiver<U>where
MpscReceiver<U>: Upcast<Self>,
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: 'static + Send> MpscReceiver<T>
impl<T: 'static + Send> MpscReceiver<T>
sourcepub fn new() -> Self
pub fn new() -> Self
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: 'static + Send> Default for MpscReceiver<T>
impl<T: 'static + Send> Default for MpscReceiver<T>
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: 'static + Send> FusedStream for MpscReceiver<T>
impl<T: 'static + Send> FusedStream for MpscReceiver<T>
source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns
true
if the stream should no longer be polled.source§impl<T: 'static + Send> Stream for MpscReceiver<T>
impl<T: 'static + Send> Stream for MpscReceiver<T>
source§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.