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 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.
§Errors
Returns a value of its associated error type if the buffer provision fails.