pub struct Sender<T, Codec = Json, const BUFFER: usize = remoc::::rch::mpsc::sender::Sender::{constant#0}> { /* private fields */ }Expand description
Implementations§
Source§impl<T, Codec, const BUFFER: usize> Sender<T, Codec, BUFFER>where
T: Send + 'static,
impl<T, Codec, const BUFFER: usize> Sender<T, Codec, BUFFER>where
T: Send + 'static,
Sourcepub async fn send(&self, value: T) -> Result<(), SendError<T>>
pub async fn send(&self, value: T) -> Result<(), SendError<T>>
Sends a value over this channel.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed and this function may return errors caused by previous invocations.
Sourcepub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
Attempts to immediately send a message over this channel.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed and this function may return errors caused by previous invocations.
Sourcepub fn blocking_send(&self, value: T) -> Result<(), SendError<T>>
pub fn blocking_send(&self, value: T) -> Result<(), SendError<T>>
Blocking send to call outside of asynchronous contexts.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed and this function may return errors caused by previous invocations.
§Panics
This function panics if called within an asynchronous execution context.
Sourcepub async fn reserve(&self) -> Result<Permit<T>, SendError<()>>
pub async fn reserve(&self) -> Result<Permit<T>, SendError<()>>
Wait for channel capacity, returning an owned permit. Once capacity to send one message is available, it is reserved for the caller.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed and this function may return errors caused by previous invocations.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the current capacity of the channel.
Zero is returned when the channel has been closed or an error has occurred.
Sourcepub async fn closed(&self)
pub async fn closed(&self)
Completes when the receiver has been closed, dropped or the connection failed.
Use closed_reason to obtain the cause for closure.
Sourcepub fn closed_reason(&self) -> Option<ClosedReason>
pub fn closed_reason(&self) -> Option<ClosedReason>
Returns the reason for why the channel has been closed.
Returns None if the channel is not closed.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether the receiver has been closed, dropped or the connection failed.
Use closed_reason to obtain the cause for closure.
Sourcepub fn set_codec<NewCodec>(self) -> Sender<T, NewCodec, BUFFER>
pub fn set_codec<NewCodec>(self) -> Sender<T, NewCodec, BUFFER>
Sets the codec that will be used when sending this sender to a remote endpoint.
Sourcepub fn set_buffer<const NEW_BUFFER: usize>(self) -> Sender<T, Codec, NEW_BUFFER>
pub fn set_buffer<const NEW_BUFFER: usize>(self) -> Sender<T, Codec, NEW_BUFFER>
Sets the buffer size that will be used when sending this sender to a remote endpoint.
Sourcepub fn max_item_size(&self) -> usize
pub fn max_item_size(&self) -> usize
The maximum allowed item size in bytes.
Sourcepub fn set_max_item_size(&mut self, max_item_size: usize)
pub fn set_max_item_size(&mut self, max_item_size: usize)
Sets the maximum allowed item size in bytes.
Trait Implementations§
Source§impl<'de, T, Codec, const BUFFER: usize> Deserialize<'de> for Sender<T, Codec, BUFFER>where
T: RemoteSend,
Codec: Codec,
impl<'de, T, Codec, const BUFFER: usize> Deserialize<'de> for Sender<T, Codec, BUFFER>where
T: RemoteSend,
Codec: Codec,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Sender<T, Codec, BUFFER>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Sender<T, Codec, BUFFER>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserializes this sender after it has been received over a chmux channel.
Source§impl<T, Codec, const BUFFER: usize> Serialize for Sender<T, Codec, BUFFER>where
T: RemoteSend,
Codec: Codec,
impl<T, Codec, const BUFFER: usize> Serialize for Sender<T, Codec, BUFFER>where
T: RemoteSend,
Codec: Codec,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serializes this sender for sending over a chmux channel.