pub trait Keyed: Declared + Wire {
// Required methods
fn payload<'a>(&'a self, parts: &mut Vec<&'a dyn AnyWire>);
fn open_payload(number: u64, at: usize) -> Result<Opened, DecodeError>;
// Provided methods
fn payload_bytes(&self) -> Vec<u8> ⓘ { ... }
fn decode_payload(number: u64, bytes: &[u8]) -> Result<Self, DecodeError> { ... }
}Expand description
An enum written as one constructor’s payload alone, its constructor
told apart outside the bytes, as a host note’s name tells which note it
is (trace.md, Host notes). wire! gives it to
every enum, whose Wire::write is its constructor’s number and then
this.
Required Methods§
Sourcefn payload<'a>(&'a self, parts: &mut Vec<&'a dyn AnyWire>)
fn payload<'a>(&'a self, parts: &mut Vec<&'a dyn AnyWire>)
Pushes its payload’s parts to parts, in the order they are
written, without its constructor’s number.
Sourcefn open_payload(number: u64, at: usize) -> Result<Opened, DecodeError>
fn open_payload(number: u64, at: usize) -> Result<Opened, DecodeError>
Opens the payload of the constructor written with number, the
number read at byte at.
§Errors
A DecodeError when no constructor is written with number.
Provided Methods§
Sourcefn payload_bytes(&self) -> Vec<u8> ⓘ
fn payload_bytes(&self) -> Vec<u8> ⓘ
Its payload’s bytes.
Sourcefn decode_payload(number: u64, bytes: &[u8]) -> Result<Self, DecodeError>
fn decode_payload(number: u64, bytes: &[u8]) -> Result<Self, DecodeError>
The one value of the constructor written with number whose
payload bytes hold, and nothing else.
§Errors
A DecodeError when no constructor is written with number,
the bytes are not its payload’s, or bytes are left over.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".