pub struct WeightedSender<T> { /* private fields */ }Expand description
The sending half of a weighted channel. Cloneable and shareable across tasks.
Implementations§
Source§impl<T: Weigh> WeightedSender<T>
impl<T: Weigh> WeightedSender<T>
Sourcepub async fn send(&self, value: T) -> Result<(), SendError<T>>
pub async fn send(&self, value: T) -> Result<(), SendError<T>>
Send a message, waiting until there is room in the budget for its weight.
Waits (asynchronously) while the messages already in the channel plus this
one would exceed the budget, then delivers it. A message that weighs more
than the whole budget is handled per the channel’s Oversized policy.
§Errors
SendError::Closedif the receiver has been dropped.SendError::TooLargeif the message weighs more than the budget and the policy isOversized::Reject.
Sourcepub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
pub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
Try to send a message without waiting.
Like send, but never waits: if admitting the message would
exceed the budget, or the count buffer is full, it returns
TrySendError::Full right away instead of waiting for room. A message that
weighs more than the whole budget is handled per the channel’s Oversized
policy.
§Errors
TrySendError::Fullif there is no room right now (weight budget or count buffer).TrySendError::Closedif the receiver has been dropped.TrySendError::TooLargeif the message weighs more than the budget and the policy isOversized::Reject.
Sourcepub fn max_weight(&self) -> usize
pub fn max_weight(&self) -> usize
The channel’s total weight budget (the value passed to Builder::new).
Sourcepub fn available_weight(&self) -> usize
pub fn available_weight(&self) -> usize
Budget not currently reserved by messages in the channel, in weight units.