pub trait Buffer: Sized + Debug {
// Required methods
fn capacity_range() -> (usize, usize);
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§
Sourcefn capacity_range() -> (usize, usize)
fn capacity_range() -> (usize, usize)
Returns the capacity range (min, max)
for this buffer type.
Sourcefn limits(&self) -> BufferLimits
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.
Sourcefn target_capacity(&self) -> usize
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.
Sourcefn request_capacity(&mut self, size: usize)
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.