pub trait ChannelProducer<'a, ItemType, DerivedItemType>where
    ItemType: Debug + Send + Sync,
    DerivedItemType: 'a + Debug,{
    // Required methods
    fn send(&self, item: ItemType) -> RetryResult<(), ItemType, (), ()>;
    fn send_with<F>(&self, setter: F) -> RetryResult<(), F, (), ()>
       where F: FnOnce(&mut ItemType);

    // Provided method
    fn send_derived(&self, _derived_item: &DerivedItemType) -> bool { ... }
}
Expand description

Defines how to send events (to a [Uni] or [Multi]).

Required Methods§

source

fn send(&self, item: ItemType) -> RetryResult<(), ItemType, (), ()>

Similar to Self::send_with(), but for sending the already-built item.
See there for how to deal with the returned type. IMPLEMENTORS: #[inline(always)]

source

fn send_with<F>(&self, setter: F) -> RetryResult<(), F, (), ()>where F: FnOnce(&mut ItemType),

Calls setter, passing a slot so the payload may be filled there, then sends the event through this channel asynchronously.
The returned type is conversible to Result<(), F> by calling .into() on it, returning Err<setter> when the buffer is full, to allow the caller to try again; otherwise you may add any retrying logic using the keen-retry crate’s API like in:

    xxxx.send_with(|slot| *slot = 42)
        .retry_with(|setter| xxxx.send_with(setter))
        .spinning_until_timeout(Duration::from_millis(300), ())     // go see the other options
        .map_errors(|_, setter| (setter, _), |e| e)                 // map the unconsumed `setter` payload into `Err(setter)` when converting to `Result` ahead
        .into()?;

NOTE: this type may allow the compiler some extra optimization steps when compared to Self::send(). When tuning for performance, it is advisable to try this method IMPLEMENTORS: #[inline(always)]

Provided Methods§

source

fn send_derived(&self, _derived_item: &DerivedItemType) -> bool

For channels that stores the DerivedItemType instead of the ItemType, this method may be useful – for instance: if the Stream consumes Arc<String> (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)]

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'a, ItemType, OgreAllocatorType, 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>where ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Sync + Send,

source§

impl<'a, ItemType, OgreAllocatorType, 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>where ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Sync + Send,

source§

impl<'a, ItemType, OgreAllocatorType, 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>where ItemType: 'a + Send + Sync + Debug, OgreAllocatorType: OgreAllocator<ItemType> + 'a + Send + Sync,

source§

impl<'a, ItemType, OgreAllocatorType, 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>where ItemType: 'a + Debug + Send + Sync, OgreAllocatorType: 'a + OgreAllocator<ItemType> + Send + Sync,

source§

impl<'a, ItemType, 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>where ItemType: 'a + Send + Sync + Debug + Default,

source§

impl<'a, ItemType, 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>where ItemType: 'a + Send + Sync + Debug,

source§

impl<'a, ItemType, 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>where ItemType: 'a + Send + Sync + Debug + Default,

source§

impl<'a, ItemType, 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>where ItemType: 'a + Send + Sync + Debug + Default,

source§

impl<'a, ItemType, 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>where ItemType: 'a + Send + Sync + Debug,

source§

impl<'a, ItemType, 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>where ItemType: Send + Sync + Debug + Default + 'a,

source§

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