pub trait BufferProvider<'a> {
type Buffer: AsMut<[u8]> + Into<Bytes<'a>>;
type ProvisionError: Debug;
// Required method
fn provide_buffer(
&mut self,
len: usize,
) -> Result<Self::Buffer, Self::ProvisionError>;
}Expand description
A trait to describe anything that can allocate memory.
Returned memory can be borrowed or owned. Either way, it is bound by the 'a
lifetime - usually just the lifetime of the underlying buffer.
The client does not store any references to memory returned by this provider.
Required Associated Types§
Sourcetype Buffer: AsMut<[u8]> + Into<Bytes<'a>>
type Buffer: AsMut<[u8]> + Into<Bytes<'a>>
The type returned from a successful buffer provision.
Must implement AsMut<[u8]> so that it can be borrowed mutably right after allocation for initialization
and Into<Bytes<'a>> for storing.
Sourcetype ProvisionError: Debug
type ProvisionError: Debug
The error type returned from a failed buffer provision.
Required Methods§
Sourcefn provide_buffer(
&mut self,
len: usize,
) -> Result<Self::Buffer, Self::ProvisionError>
fn provide_buffer( &mut self, len: usize, ) -> Result<Self::Buffer, Self::ProvisionError>
If successful, returns contiguous memory with a size in bytes of the len argument.