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 { ... }
}
Available on crate feature std only.
Expand description

encode(writer) for any BitEncode message — encodes to a Vec (using the type’s LAYOUT) verbatim 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 with the std feature; in no_std use the generated to_bytes/to_canonical_bytes, or bit_encode/canonical_bit_encode over a Sink.

Provided Methods§

Source

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

Encodes self verbatim to any std::io::Write (socket, file, Vec) — exactly what’s stored. For the canonical form, encode self.to_canonical().encode(&mut w), or use the inherent to_bytes (verbatim) / to_canonical_bytes (canonical) instead.

§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§