pub trait Encoder {
type Error;
// Required methods
fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>;
fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>;
}
๐Deprecated since 0.2.2: The
Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.Expand description
A type that can handle an Encodable
type
An encoder is responsible for writing bytes into a buffer or other destination. Encoders are used by encodables to write their data. Thus, encoders must uphold the same properties as encodables.
Required Associated Typesยง
Sourcetype Error
๐Deprecated since 0.2.2: The Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.
type Error
Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.The error type that can be returned when encoding a value.
For example, some encoders may return an error if the underlying buffer is full
Required Methodsยง
Sourcefn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>
๐Deprecated since 0.2.2: The Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.
fn put_slice(&mut self, slice: &[u8]) -> Result<(), Self::Error>
Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.Copies a slice of bytes into the encoder
ยงErrors
Implementations of this method should return an error if the underlying encoder fails to write the slice of bytes.
Sourcefn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>
๐Deprecated since 0.2.2: The Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.
fn put_byte(&mut self, byte: u8) -> Result<(), Self::Error>
Encoder
trait has been deprecated in favor of multiple encoder traits. Please use ByteEncoder
, StrEncoder
, or BaseEncoder
depending on your needs. The Encoder
trait will be removed in 1.0.0.Appends a single byte into the encoder, if possible.
ยงErrors
Implementations of this method should return an error if the underlying encoder fails to write the byte.