pub trait Buffer: Takeable + Debug + Sized {
    // Required methods
    fn limits(&self) -> BufferLimits;
    fn target_capacity(&self) -> usize;
    fn request_capacity(&mut self, size: usize);
Expand description

Common super trait for both sending and receiving buffer.

Required Methods§


fn limits(&self) -> BufferLimits

Returns information about the number of bytes in the buffer.

Returns a BufferLimits instance with information about the number of bytes in the buffer.


fn target_capacity(&self) -> usize

Gets the target size of the buffer, in bytes.

The target capacity of the buffer is distinct from the actual capacity (returned by [Buffer::capacity]) in that the target capacity should remain fixed unless requested otherwise, while the actual capacity can vary with usage.

For fixed-size buffers this should return the same result as calling self.capacity(). For buffer types that support resizing, the returned value can be different but should not change unless a resize was requested.


fn request_capacity(&mut self, size: usize)

Requests that the buffer be resized to hold the given number of bytes.

Calling this method suggests to the buffer that it should alter its size. Implementations are free to impose constraints or ignore requests entirely.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§


impl Buffer for Arc<Mutex<RingBuffer>>