[−][src]Struct multistream_batch::buf_batch::BufBatch
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
Auto Trait Implementations
impl<I> Send for BufBatch<I> where
I: Send,
I: Send,
impl<I> Unpin for BufBatch<I> where
I: Unpin,
I: Unpin,
impl<I> Sync for BufBatch<I> where
I: Sync,
I: Sync,
impl<I> UnwindSafe for BufBatch<I> where
I: UnwindSafe,
I: UnwindSafe,
impl<I> RefUnwindSafe for BufBatch<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,