[−][src]Struct multistream_batch::buf_batch::BufBatch
Batches items in internal buffer up to max_size
items or until max_duration
has elapsed
since the first item appended to the batch.
This base implementation does not handle actual awaiting for batch duration timeout.
Implementations
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 the number of items stored (max_size
)
and maximum duration that batch can last (max_duration
) since the first item appended to it.
Panics if max_size == 0
.
pub fn poll(&self) -> PollResult
[src]
Checks if the batch has reached one of its limits.
Returns:
PollResult::Ready
- batch has reached one of its limits and is ready to be consumed,PollResult::NotReady(None)
- batch is not ready yet and has no items appended 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 a reference to that item.
It is a contract error to append batch that is ready according to self.poll()
.
Panics if the batch has already reached its max_size
limit.
pub fn clear(&mut self)
[src]
Starts a new batch by dropping all buffered items.
pub fn drain(&mut self) -> Drain<I>
[src]
Starts a new batch by draining all buffered items.
pub fn pop(&mut self) -> Option<I>
[src]
Pops last item from internal buffer.
pub fn remove(&mut self, index: usize) -> I
[src]
Removes item from internal buffer at index.
Panics if index is out of bounds.
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> RefUnwindSafe for BufBatch<I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<I> Send for BufBatch<I> where
I: Send,
I: Send,
impl<I> Sync for BufBatch<I> where
I: Sync,
I: Sync,
impl<I> Unpin for BufBatch<I> where
I: Unpin,
I: Unpin,
impl<I> UnwindSafe for BufBatch<I> where
I: UnwindSafe,
I: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,