[][src]Struct multistream_batch::channel::buf_batch::BufBatchChannel

pub struct BufBatchChannel<I: Debug> { /* fields omitted */ }

Batches items in internal buffer up to max_size items or until max_duration has elapsed since first item was appended to the batch.

Methods

impl<I: Debug> BufBatchChannel<I>[src]

pub fn new(
    max_size: usize,
    max_duration: Duration,
    channel_size: usize
) -> (Sender<Command<I>>, BufBatchChannel<I>)
[src]

Creates batch given maximum batch size in number of items (max_size) and maximum duration that batch can last (max_duration) since first item appended to it. It also returns Sender endpoint into which Commands can be sent.

Panics if max_size == 0.

pub fn with_producer_thread(
    max_size: usize,
    max_duration: Duration,
    channel_size: usize,
    producer: impl FnOnce(Sender<Command<I>>) + Send + 'static
) -> BufBatchChannel<I> where
    I: Send + 'static, 
[src]

Crates batch calling producer closure with Sender end of the channel in newly started thread.

pub fn next(&mut self) -> Result<Drain<I>, EndOfStreamError>[src]

Gets next ready batch as Drain iterator of its items.

This call will block until batch becomes ready.

Returns Err(EndOfStreamError) after Sender end was dropped and all batched items were flushed.

pub fn is_disconnected(&self) -> bool[src]

Checks if previous self.next() call found channel to be disconnected.

pub fn clear(&mut self)[src]

Starts new batch dropping all buffered items.

pub fn drain(&mut self) -> Drain<I>[src]

Starts new batch by draining all buffered items.

pub fn into_vec(self) -> Vec<I>[src]

Converts into internal item buffer.

pub fn as_slice(&self) -> &[I][src]

Returns slice of internal item buffer.

Trait Implementations

impl<I: Debug> Debug for BufBatchChannel<I>[src]

Auto Trait Implementations

impl<I> Unpin for BufBatchChannel<I> where
    I: Unpin

impl<I> Sync for BufBatchChannel<I> where
    I: Send + Sync

impl<I> Send for BufBatchChannel<I> where
    I: Send

impl<I> UnwindSafe for BufBatchChannel<I> where
    I: UnwindSafe

impl<I> RefUnwindSafe for BufBatchChannel<I> where
    I: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]