[][src]Struct multistream_batch::buf_batch::BufBatch

pub struct BufBatch<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.

This base implementation does not handle actual awaiting for batch duration timeout.

Methods

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

pub fn new(max_size: usize, max_duration: Duration) -> BufBatch<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.

Panics if max_size == 0.

pub fn poll(&self) -> PollResult[src]

Checks if batch has reached one of its limits.

Returns:

  • PollResult::Ready - batch has reached one of its limit and is ready to be consumed,
  • PollResult::NotReady(None) - batch is not ready yet and has no items appeded yet,
  • PollResult::NotReady(Some(duration)) - batch is not ready yet but it will be ready after time duration due to duration limit.

pub fn append(&mut self, item: I) -> &I[src]

Appends item to batch and returns reference to that item.

It is an contract error to append batch that is ready according to self.poll().

Panics if batch has already reached its max_size limit.

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 BufBatch<I>[src]

Auto Trait Implementations

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

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

impl<I> Sync for BufBatch<I> where
    I: Sync

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

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

Blanket Implementations

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

impl<T> From<T> for 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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