Skip to main content

Shaped

Trait Shaped 

Source
pub trait Shaped: Sized + 'static {
    const FORM: WireForm;

    // Required methods
    fn write_at(
        &self,
        out: &mut ValueWriter<'_, '_>,
        ty: &Type,
    ) -> Result<(), EncodeError>;
    fn read_at(
        input: &mut ValueReader<'_, '_, '_>,
        ty: &Type,
    ) -> Result<Self, DecodeError>;
}
Expand description

A Rust type mapped to a Flow type: its WireForm, and its values written and read at the Flow type its form projects to, part by part, as the value encoding has them.

Required Associated Constants§

Source

const FORM: WireForm

How a value of it is written.

Required Methods§

Source

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Writes it as a value of ty, the Flow type its form projects to in out’s catalog.

§Errors

An EncodeError when its form has no Flow type, ty is not that type, or the value is out of a form its type holds it to.

Source

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Self, DecodeError>

Reads one, a value of ty in input’s catalog.

§Errors

A DecodeError when ty is not the type its form projects to, or the bytes are not a value of ty that is one of its own.

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 Shaped for !

Never, which has no values.

Source§

const FORM: WireForm = WireForm::Never

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<!, DecodeError>

Source§

impl Shaped for ()

Source§

const FORM: WireForm = WireForm::Unit

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(), DecodeError>

Source§

impl Shaped for Bytes

Source§

const FORM: WireForm = WireForm::Bytes

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Bytes, DecodeError>

Source§

impl Shaped for Call

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Call, DecodeError>

Source§

impl Shaped for Duration

duration.Duration, as a length its Rust type can hold: one that is negative or finer than a nanosecond is none.

Source§

const FORM: WireForm = WireForm::Duration

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Duration, DecodeError>

Source§

impl Shaped for Flags

Source§

const FORM: WireForm

Source§

fn write_at( &self, catalog: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( catalog: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Flags, DecodeError>

Source§

impl Shaped for Log

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Log, DecodeError>

Source§

impl Shaped for Message

Source§

const FORM: WireForm

Source§

fn write_at( &self, catalog: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( catalog: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Message, DecodeError>

Source§

impl Shaped for OsString

An OS string is written as its bytes, as Bytes is, never through a lossy text: the platform’s own encoding of it, which off Unix is a superset of UTF-8. Off Unix it reads back only when those bytes are UTF-8, and is refused otherwise.

Source§

const FORM: WireForm = WireForm::Bytes

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<OsString, DecodeError>

Source§

impl Shaped for PathBuf

path.Path: its normal text, its components joined by / whatever the host’s separator, so a path that is not UTF-8 is none.

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<PathBuf, DecodeError>

Source§

impl Shaped for Reply

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Reply, DecodeError>

Source§

impl Shaped for String

Source§

const FORM: WireForm = WireForm::Text

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<String, DecodeError>

Source§

impl Shaped for SystemTime

time.Instant, as an instant the platform’s clock can hold.

Source§

const FORM: WireForm = WireForm::Instant

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<SystemTime, DecodeError>

Source§

impl Shaped for bool

Source§

const FORM: WireForm = WireForm::Bool

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<bool, DecodeError>

Source§

impl Shaped for u64

Source§

const FORM: WireForm = WireForm::Number

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<u64, DecodeError>

Source§

impl<A, B, C, D, E, F, G, H> Shaped for (A, B, C, D, E, F, G, H)
where A: Shaped, B: Shaped, C: Shaped, D: Shaped, E: Shaped, F: Shaped, G: Shaped, H: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C, D, E, F, G, H), DecodeError>

Source§

impl<A, B, C, D, E, F, G> Shaped for (A, B, C, D, E, F, G)
where A: Shaped, B: Shaped, C: Shaped, D: Shaped, E: Shaped, F: Shaped, G: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C, D, E, F, G), DecodeError>

Source§

impl<A, B, C, D, E, F> Shaped for (A, B, C, D, E, F)
where A: Shaped, B: Shaped, C: Shaped, D: Shaped, E: Shaped, F: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C, D, E, F), DecodeError>

Source§

impl<A, B, C, D, E> Shaped for (A, B, C, D, E)
where A: Shaped, B: Shaped, C: Shaped, D: Shaped, E: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C, D, E), DecodeError>

Source§

impl<A, B, C, D> Shaped for (A, B, C, D)
where A: Shaped, B: Shaped, C: Shaped, D: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C, D), DecodeError>

Source§

impl<A, B, C> Shaped for (A, B, C)
where A: Shaped, B: Shaped, C: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B, C), DecodeError>

Source§

impl<A, B> Shaped for (A, B)
where A: Shaped, B: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<(A, B), DecodeError>

Source§

impl<K, V> Shaped for BTreeMap<K, V>
where K: Shaped + Ord, V: Shaped,

A dictionary, its entries in Flow’s order of its keys whatever Rust’s is.

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<BTreeMap<K, V>, DecodeError>

Source§

impl<T, E> Shaped for Result<T, E>
where T: Shaped, E: Shaped,

std’s Result: Ok then Err, as std declares them, whichever numbers a catalog gives them.

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Result<T, E>, DecodeError>

Source§

impl<T> Shaped for BTreeSet<T>
where T: Shaped + Ord,

A set, its values in Flow’s order whatever Rust’s is.

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<BTreeSet<T>, DecodeError>

Source§

impl<T> Shaped for Box<T>
where T: Shaped,

Source§

const FORM: WireForm = T::FORM

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Box<T>, DecodeError>

Source§

impl<T> Shaped for Option<T>
where T: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Option<T>, DecodeError>

Source§

impl<T> Shaped for Vec<T>
where T: Shaped,

Source§

const FORM: WireForm

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<Vec<T>, DecodeError>

Source§

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

A run of exactly N bytes, written as Bytes are: a run of any other length is not one.

Source§

const FORM: WireForm = WireForm::Bytes

Source§

fn write_at( &self, out: &mut ValueWriter<'_, '_>, ty: &Type, ) -> Result<(), EncodeError>

Source§

fn read_at( input: &mut ValueReader<'_, '_, '_>, ty: &Type, ) -> Result<[u8; N], DecodeError>

Implementors§

Source§

impl Shaped for Ack

Source§

impl Shaped for Body

Source§

impl Shaped for flow_toolkit::data::Bytes

Source§

const FORM: WireForm = WireForm::Bytes

Source§

impl Shaped for CallRef

Source§

const FORM: WireForm = WireForm::CallRef

Source§

impl Shaped for CallTypes

Source§

impl Shaped for Constructor

Source§

impl Shaped for DataVersion

Source§

impl Shaped for Decimal

Source§

const FORM: WireForm = WireForm::Decimal

Source§

impl Shaped for Digest

A digest is written as its 32 bytes.

Source§

const FORM: WireForm = WireForm::Bytes

Source§

impl Shaped for flow_toolkit::Duration

Source§

const FORM: WireForm = WireForm::Duration

Source§

impl Shaped for Encoded

Its form is never read: #[tool] declares a type parameter by its place-holder, flow_abi::wire::Param, and the derive of a std declaration writes the declaration’s form.

Source§

impl Shaped for Field

Source§

impl Shaped for Identity

Source§

impl Shaped for Instant

Source§

const FORM: WireForm = WireForm::Instant

Source§

impl Shaped for Int

Source§

const FORM: WireForm = WireForm::Int

Source§

impl Shaped for JsonValue

Source§

impl Shaped for Level

Source§

impl Shaped for Library

Source§

impl Shaped for MediaType

Source§

impl Shaped for NoType

Source§

impl Shaped for Owner

Source§

impl Shaped for Payload

Source§

impl Shaped for Program

Source§

impl Shaped for Rest

Source§

const FORM: WireForm = WireForm::Rest

Source§

impl Shaped for flow_abi::description::ResultType

Source§

impl Shaped for flow_abi::metadata::ResultType

As TypeSpec’s: the bytes it was read from, read and validated by ResultType::read_from.

Source§

const FORM: WireForm = <described::ResultType as Shaped>::FORM

Source§

impl Shaped for RunId

Source§

const FORM: WireForm = WireForm::RunId

Source§

impl Shaped for Template

Source§

impl Shaped for Term

Source§

impl Shaped for ToolProblem

std’s ToolProblem, its constructors found by name in the enum the catalog declares.

Source§

impl Shaped for flow_abi::description::TypeSpec

Source§

impl Shaped for flow_abi::metadata::TypeSpec

A validated description is written as the bytes it was read from, and read as TypeSpec::read_from reads and validates it; its form and its value are its declared description’s.

Source§

const FORM: WireForm = <described::TypeSpec as Shaped>::FORM

Source§

impl Shaped for UnixMillis

A time is written as the value encoding writes an Instant, which is how a note keeps one (trace.md, Host notes): an Instant that is not a whole number of milliseconds in the range is no such time.

Source§

const FORM: WireForm = WireForm::Instant

Source§

impl Shaped for Untyped

Source§

impl Shaped for Url

Source§

impl Shaped for Versioned

Source§

impl<V> Shaped for Outcome<V>
where V: Shaped,

Source§

impl<const INDEX: usize> Shaped for Param<INDEX>