Skip to main content

EncodeExt

Trait EncodeExt 

Source
pub trait EncodeExt: BitEncode {
    // Provided method
    fn encode<W: Write>(&self, w: &mut W) -> Result<(), BitError>
       where Self: Sized { ... }
}
Expand description

encode(writer) for any BitEncode message — encodes to a Vec (using the type’s LAYOUT) and writes it to a std::io::Write sink. A blanket-implemented extension trait, so bring it into scope (use bnb::prelude::* or use bnb::EncodeExt) to call .encode(&mut w). Only available with the std feature; in no_std use BitEncode’s generated to_bytes/encode_into.

Provided Methods§

Source

fn encode<W: Write>(&self, w: &mut W) -> Result<(), BitError>
where Self: Sized,

Encodes self to any std::io::Write (socket, file, Vec).

§Errors

ErrorKind::Io on a write failure, else the encode error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: BitEncode> EncodeExt for T

Available on crate feature std only.