pub trait Wire: Shaped {
// Required methods
fn write_head<'a>(
&'a self,
out: &mut Vec<u8>,
parts: &mut Vec<&'a dyn AnyWire>,
);
fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>;
// Provided methods
fn write(&self, out: &mut Vec<u8>) { ... }
fn read(reader: &mut Reader<'_>) -> Result<Self, DecodeError> { ... }
fn bytes(&self) -> Vec<u8> ⓘ { ... }
fn decode(bytes: &[u8]) -> Result<Self, DecodeError> { ... }
}Expand description
A type with a binary form of its own: written and read part by part, as
its WireForm says.
Required Methods§
Sourcefn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)
fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)
Appends the bytes it writes before its parts to out, and pushes
its parts to parts in the order they are written after them.
Sourcefn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>
fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>
Reads its head at reader: the value itself when it has no parts,
else its parts to read and what joins them.
§Errors
A DecodeError when the bytes there are not one’s head.
Provided Methods§
Sourcefn write(&self, out: &mut Vec<u8>)
fn write(&self, out: &mut Vec<u8>)
Appends its bytes to out: its head, and then each part’s bytes in
order, written over a stack on the heap, so a value nested however
deep is written on a native stack of fixed size.
Sourcefn read(reader: &mut Reader<'_>) -> Result<Self, DecodeError>
fn read(reader: &mut Reader<'_>) -> Result<Self, DecodeError>
Reads one from reader, leaving the reader just past it.
§Errors
A DecodeError when the bytes there are not one’s.
Sourcefn decode(bytes: &[u8]) -> Result<Self, DecodeError>
fn decode(bytes: &[u8]) -> Result<Self, DecodeError>
The one value bytes hold, and nothing else.
§Errors
A DecodeError when the bytes are not one’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".
Implementations on Foreign Types§
Source§impl Wire for CallRef
A call id is written as history writes it (trace.md, Facts): its
segment, its task id and its counter.
impl Wire for CallRef
A call id is written as history writes it (trace.md, Facts): its
segment, its task id and its counter.
Source§impl Wire for RunId
A run id is its 16 bits, most significant byte first, with no length
(abi.md, Numbers and text).
impl Wire for RunId
A run id is its 16 bits, most significant byte first, with no length
(abi.md, Numbers and text).