pub trait OctetsBuilder {
type AppendError: Into<ShortBuf>;
// Required method
fn append_slice(&mut self, slice: &[u8]) -> Result<(), Self::AppendError>;
}Expand description
A buffer to construct an octet sequence.
Octet builders represent a buffer of space available for building an octets sequence by appending the contents of octet slices. The buffers may consist of a predefined amount of space or grow as needed.
Octet builders provide access to the already assembled data through
octet slices via their implementations of AsRef<[u8]> and
AsMut<[u8]>.
Required Associated Types§
Sourcetype AppendError: Into<ShortBuf>
type AppendError: Into<ShortBuf>
The error type when appending data fails.
There are exactly two options for this type: Builders where appending
never fails use Infallible. Builders with a limited buffer which
may have insufficient space for appending use ShortBuf.
The trait bound on the type allows upgrading the error to ShortBuf
even for builders with unlimited space. This way, an error type for
operations that use a builder doesn’t need to be generic over the
append error type and can simply use a variant for anything
Into<ShortBuf> instead.
Required Methods§
Sourcefn append_slice(&mut self, slice: &[u8]) -> Result<(), Self::AppendError>
fn append_slice(&mut self, slice: &[u8]) -> Result<(), Self::AppendError>
Appends the content of a slice to the builder.
If there isn’t enough space available for appending the slice, returns an error and leaves the builder alone.