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§

source

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)]

source

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§

source

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]

source

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 derived item type) and the channel is for Strings. With this method one may send an Arc directly.
The default implementation, though, is made for types that don’t have a derived item type.
IMPLEMENTORS: #[inline(always)]

Implementors§

source§

impl<'a, ItemType: 'a + Debug + Send + Sync, OgreAllocatorType: 'a + OgreAllocator<ItemType> + Send + Sync, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, OgreUnique<ItemType, OgreAllocatorType>> for reactive_mutiny::uni::channels::zero_copy::full_sync::FullSync<'a, ItemType, OgreAllocatorType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Send + Sync, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, OgreUnique<ItemType, OgreAllocatorType>> for reactive_mutiny::uni::channels::zero_copy::atomic::Atomic<'a, ItemType, OgreAllocatorType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Sync + Send, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, OgreArc<ItemType, OgreAllocatorType>> for reactive_mutiny::multi::channels::ogre_arc::atomic::Atomic<'a, ItemType, OgreAllocatorType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Sync + Send, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, OgreArc<ItemType, OgreAllocatorType>> for reactive_mutiny::multi::channels::ogre_arc::full_sync::FullSync<'a, ItemType, OgreAllocatorType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, Arc<ItemType>> for reactive_mutiny::multi::channels::arc::atomic::Atomic<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, Arc<ItemType>> for reactive_mutiny::multi::channels::arc::crossbeam::Crossbeam<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, Arc<ItemType>> for reactive_mutiny::multi::channels::arc::full_sync::FullSync<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, ItemType> for reactive_mutiny::uni::channels::movable::atomic::Atomic<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, ItemType> for reactive_mutiny::uni::channels::movable::crossbeam::Crossbeam<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>

source§

impl<'a, ItemType: 'a + Send + Sync + Debug, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, &'static ItemType> for MmapLog<'a, ItemType, MAX_STREAMS>

source§

impl<'a, ItemType: Send + Sync + Debug + 'a, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> ChannelProducer<'a, ItemType, ItemType> for reactive_mutiny::uni::channels::movable::full_sync::FullSync<'a, ItemType, BUFFER_SIZE, MAX_STREAMS>