Trait Encodable

Source
pub trait Encodable: Sized {
    type Error;

    // Required methods
    fn encoded_len(&self) -> usize;
    fn encode(&self, buf: &mut [u8]) -> Result<(), Self::Error>;
}
Expand description

An encodable type can write itself into a byte buffer.

Required Associated Types§

Required Methods§

Source

fn encoded_len(&self) -> usize

Returns the number of bytes necessary to encode |self|.

Source

fn encode(&self, buf: &mut [u8]) -> Result<(), Self::Error>

Writes the encoded version of |self| at the start of |buf|. |buf| must be at least |self.encoded_len()| length.

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.

Implementors§

impl Encodable for ServiceCapability

impl Encodable for StreamInformation

impl Encodable for Header

impl Encodable for HeaderSet

impl Encodable for TagLengthValue

impl<T> Encodable for Packet<T>
where T: Clone + Debug + PartialEq, for<'a> &'a T: Into<u8>,

impl Encodable for FrameData

impl Encodable for UIHData

impl Encodable for MuxCommandParams

impl Encodable for FlowControlParams

impl Encodable for ModemStatusParams

impl Encodable for MuxCommand

impl Encodable for NonSupportedCommandParams

impl Encodable for ParameterNegotiationParams

impl Encodable for RemoteLineStatusParams

impl Encodable for RemotePortNegotiationParams

impl Encodable for TestCommandParams

impl Encodable for Frame

impl Encodable for UserData