Trait reactive_mutiny::types::ChannelProducer
source · pub trait ChannelProducer<'a, ItemType: Debug + Send + Sync, DerivedItemType: 'a + Debug> {
// Required methods
fn try_send<F: FnOnce(&mut ItemType)>(&self, setter: F) -> bool;
fn try_send_movable(&self, item: ItemType) -> bool;
// Provided methods
fn send<F: FnOnce(&mut ItemType)>(&self, _setter: F) { ... }
fn send_derived(&self, _derived_item: &DerivedItemType) { ... }
}Expand description
Defines how to send events (to a [Uni] or [Multi]).
Required Methods§
sourcefn try_send<F: FnOnce(&mut ItemType)>(&self, setter: F) -> bool
fn try_send<F: FnOnce(&mut ItemType)>(&self, setter: F) -> bool
Calls setter, passing a slot so the payload may be filled, then sends the event through this channel asynchronously.
– returns false if the buffer was full and the item wasn’t sent; true otherwise.
IMPLEMENTORS: #[inline(always)]
sourcefn try_send_movable(&self, item: ItemType) -> bool
fn try_send_movable(&self, item: ItemType) -> bool
Similar to [try_send()], but accepts the penalty that the compiler may impose of copying / moving the data around, in opposition to set it only once, in its resting place – useful to send cloned items and other objects with a custom drop IMPLEMENTORS: #[inline(always)] TODO 2023-05-17: consider restricting this entry for types that require dropping, and the zero-copy versions for those who don’t
Provided Methods§
sourcefn send<F: FnOnce(&mut ItemType)>(&self, _setter: F)
fn send<F: FnOnce(&mut ItemType)>(&self, _setter: F)
Sends an event through this channel, after calling setter to fill the payload.
If the channel is full, this function may wait until sending it is possible.
IMPLEMENTORS: #[inline(always]
sourcefn send_derived(&self, _derived_item: &DerivedItemType)
fn send_derived(&self, _derived_item: &DerivedItemType)
For channels that stores the DerivedItemType instead of the ItemType, this method may be useful
– for instance: the Stream consumes Arc
The default implementation, though, is made for types that don’t have a derived item type.
IMPLEMENTORS: #[inline(always)]