pub trait Encode {
// Required method
fn encode_slice<T: AsRef<[u8]>>(
&self,
input: T,
output: &mut [u8],
) -> Result<usize, EscnulError>;
// Provided method
fn encode<T: AsRef<[u8]>>(&self, input: T) -> Vec<u8> ⓘ { ... }
}Expand description
Trait for encoding a byte stream into a pre-allocated output buffer.
Required Methods§
Sourcefn encode_slice<T: AsRef<[u8]>>(
&self,
input: T,
output: &mut [u8],
) -> Result<usize, EscnulError>
fn encode_slice<T: AsRef<[u8]>>( &self, input: T, output: &mut [u8], ) -> Result<usize, EscnulError>
Encode input into output, returning the number of bytes written.
§Errors
EscnulError::BadEscapesif the engine’s escape byte is invalid.EscnulError::BufferTooSmallifoutputis too small. The containedProgresstells you how many bytes were produced before running out of space.
Provided Methods§
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.