pub trait BufferAlloc<Output> {
type Error;
// Required method
fn alloc(self, len: usize) -> Result<Output, Self::Error>;
}
Expand description
An object capable of allocating new buffers.
A BufferAlloc<Output>
is an object which is capable of allocating new
buffers of type Output
.
Two blanket implementations of BufferProvider
are given for any type
which implements BufferAlloc<O>
. One blanket implementation works for any
input buffer type, I
, and produces buffers of type Either<I, O>
as
output. One blanket implementation works only when the input and output
buffer types are the same, and produces buffers of that type. See the
documentation on those impls for more details.
The following implementations of BufferAlloc
are provided:
- Any
FnOnce(usize) -> Result<O, E>
implementsBufferAlloc<O, Error = E>
()
implementsBufferAlloc<Never, Error = ()>
(an allocator which always fails)new_buf_vec
implementsBufferAlloc<Buf<Vec<u8>>, Error = Never>
(an allocator which infallibly heap-allocatesVec
s)