pub struct Sender<T, Codec = Json> { /* private fields */ }Expand description
Implementations§
Source§impl<T, Codec> Sender<T, Codec>where
T: Send + 'static,
impl<T, Codec> Sender<T, Codec>where
T: Send + 'static,
Sourcepub fn send(&self, value: T) -> Result<(), SendError>
pub fn send(&self, value: T) -> Result<(), SendError>
Sends a value over this channel, notifying all receivers.
This method fails if all receivers have been dropped or become disconnected.
§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 send_modify<F>(&self, func: F)
pub fn send_modify<F>(&self, func: F)
Modifies the watched value and notifies all receivers.
This method never fails, even if all receivers have been dropped or become disconnected.
§Panics
This method panics if calling func results in a panic.
Sourcepub fn send_replace(&self, value: T) -> T
pub fn send_replace(&self, value: T) -> T
Sends a new value via the channel, notifying all receivers and returning the previous value in the channel.
This method never fails, even if all receivers have been dropped or become disconnected.
Sourcepub async fn closed(&self)
pub async fn closed(&self)
Completes when all receivers have been dropped or the connection failed.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether all receivers have been dropped or the connection failed.
Sourcepub fn subscribe(&self) -> Receiver<T, Codec>
pub fn subscribe(&self) -> Receiver<T, Codec>
Creates a new receiver subscribed to this sender.
Sourcepub fn error(&self) -> Option<SendError>
pub fn error(&self) -> Option<SendError>
Returns the error that occurred during sending to a remote endpoint, if any.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed.
Sourcepub fn clear_error(&mut self)
pub fn clear_error(&mut self)
Clears the error that occurred during sending to a remote endpoint.
Sourcepub fn check(&mut self) -> Result<(), SendError>
pub fn check(&mut self) -> Result<(), SendError>
Checks that no item-specific send error has occurred.
This method clears non-item-specific errors present on the channel.
§Error reporting
Sending and error reporting are done asynchronously. Thus, the reporting of an error may be delayed.
To verify that no item-specific send error has occurred during the lifetime of
the channel, call this method after the channel is closed, i.e.
closed has returned or is_closed is
true.
Sourcepub fn max_item_size(&self) -> usize
pub fn max_item_size(&self) -> usize
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> Deserialize<'de> for Sender<T, Codec>
impl<'de, T, Codec> Deserialize<'de> for Sender<T, Codec>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Sender<T, Codec>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Sender<T, Codec>, <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> Serialize for Sender<T, Codec>
impl<T, Codec> Serialize for Sender<T, 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.