Skip to main content

Wire

Trait Wire 

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

Source

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.

Source

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§

Source

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.

Source

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.

Source

fn bytes(&self) -> Vec<u8> ⓘ

Its bytes.

Source

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 Bytes

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

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.

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for Instant

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for Int

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for OsString

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for RunId

A run id is its 16 bits, most significant byte first, with no length (abi.md, Numbers and text).

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for String

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for bool

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl Wire for u64

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<A: Wire, B: Wire> Wire for (A, B)

Source§

fn write_head<'a>(&'a self, _: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(_: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<T: Wire, E: Wire> Wire for Result<T, E>

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<T: Wire> Wire for Box<T>

Source§

fn write_head<'a>(&'a self, _: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(_: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<T: Wire> Wire for Option<T>

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<T: Wire> Wire for Vec<T>

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, parts: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Source§

impl<const N: usize> Wire for [u8; N]

Source§

fn write_head<'a>(&'a self, out: &mut Vec<u8>, _: &mut Vec<&'a dyn AnyWire>)

Source§

fn open(reader: &mut Reader<'_>) -> Result<Opened, DecodeError>

Implementors§

Source§

impl Wire for Ack

Source§

impl Wire for Body

Source§

impl Wire for CallTypes

Source§

impl Wire for Constructor

Source§

impl Wire for DataVersion

Source§

impl Wire for Digest

Source§

impl Wire for Field

Source§

impl Wire for Identity

Source§

impl Wire for Library

Source§

impl Wire for NoType

Source§

impl Wire for Owner

Source§

impl Wire for Payload

Source§

impl Wire for Program

Source§

impl Wire for Rest

Source§

impl Wire for flow_abi::description::ResultType

Source§

impl Wire for flow_abi::ResultType

Source§

impl Wire for Template

Source§

impl Wire for Term

Source§

impl Wire for flow_abi::description::TypeSpec

Source§

impl Wire for flow_abi::TypeSpec

Source§

impl Wire for UnixMillis

Source§

impl Wire for Untyped

Source§

impl Wire for Versioned

Source§

impl<V: Wire> Wire for Outcome<V>