Function cuprate_async_buffer::new_buffer

source ·
pub fn new_buffer<T>(
    max_item_weight: usize,
) -> (BufferAppender<T>, BufferStream<T>)
Expand description

Initializes a new buffer with the provided capacity.

The capacity inputted is not the max number of items, it is the max combined weight of all items in the buffer.

It should be noted that if there are no items in the buffer then a single item of any capacity is accepted. i.e. if the capacity is 5 and there are no items in the buffer then any item even if it’s weight is >5 will be accepted.