pub trait EncodeExt: BitEncode {
// Provided method
fn encode<W: Write>(&self, w: &mut W) -> Result<(), BitError>
where Self: Sized { ... }
}std only.Expand description
encode(writer) for any BitEncode message — encodes to a Vec (using the type’s
LAYOUT) in self’s encode_mode 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§
Sourcefn encode<W: Write>(&self, w: &mut W) -> Result<(), BitError>where
Self: Sized,
fn encode<W: Write>(&self, w: &mut W) -> Result<(), BitError>where
Self: Sized,
Encodes self to any std::io::Write (socket, file, Vec) in the value’s
encode_mode — verbatim unless its mode is set to
Canonical. For an unconditional choice, 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".