Skip to main content

Schema

Trait Schema 

Source
pub trait Schema: Sized {
Show 13 methods // Required methods fn shape() -> Shape; fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>; fn write(&self) -> Value; // Provided methods fn absent() -> Option<Self> { ... } fn skip(&self) -> bool { ... } fn encode(&self, w: &mut Writer) { ... } fn decode(d: &mut Decoder<'_>) -> Option<Self> { ... } fn pack(&self, p: &mut Packer) { ... } fn unpack(u: &mut Unpacker<'_>) -> Option<Self> { ... } fn pack_list(items: &[Self], p: &mut Packer) { ... } fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>> { ... } fn encode_list(items: &[Self], w: &mut Writer) { ... } fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>> { ... }
}
Expand description

A Yog Data format.

Required Methods§

Source

fn shape() -> Shape

What the format looks like.

Source

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Reads v. Problems go to cx at its current path; None when the value couldn’t be read (the problem is in cx).

Source

fn write(&self) -> Value

The value, as the format writes it.

Provided Methods§

Source

fn absent() -> Option<Self>

The value of a field that isn’t there — None: the field is required.

Source

fn skip(&self) -> bool

Whether a struct leaves this field out when writing it.

Source

fn encode(&self, w: &mut Writer)

Writes itself in the binary form, straight — Schema::write’s value encoded, unless the type knows better (derived ones do).

Source

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Reads itself from the binary form, straight; None when it isn’t what Schema::encode writes — then read_bytes reads the slow way, which says what’s wrong. Through a value unless the type knows better (derived ones do).

Source

fn pack(&self, p: &mut Packer)

Packs itself into a frame (crate::frame): its binary form as bytes, unless the type packs itself (derived ones and plain types do).

Source

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Reads itself out of a frame; None if the bytes aren’t what Schema::pack writes.

Source

fn pack_list(items: &[Self], p: &mut Packer)

A list of these packed: a count, then each one (floats raw).

Source

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

A list of these out of a frame.

Source

fn encode_list(items: &[Self], w: &mut Writer)

A list of these written straight (numbers pack theirs).

Source

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

A list of these read straight.

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 Schema for ()

Nothing: what a call answers when it only says it’s done.

Source§

fn shape() -> Shape

Source§

fn read(_v: &ValueRef<'_>, _cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl Schema for Arc<str>

A string shared without copying.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for Box<str>

A string that won’t change: a pointer and a length, no spare capacity (String’s third word) — what big tables of names keep.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for Cow<'static, str>

Text that may be a constant: borrowed where it’s written, owned once read.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for PathBuf

A file’s path, as text (a path that isn’t Unicode loses what isn’t).

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for String

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for bool

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl Schema for f32

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

impl Schema for f64

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

impl Schema for i8

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for i16

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for i32

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for i64

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for u8

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for u16

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for u32

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for u64

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

impl Schema for usize

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn pack_list(items: &[Self], p: &mut Packer)

Source§

fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>

Source§

fn encode_list(items: &[Self], w: &mut Writer)

Source§

fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>

Source§

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

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl<A: Schema, B: Schema, C: Schema> Schema for (A, B, C)

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

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

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl<T: Schema + Ord + Clone> Schema for BTreeSet<T>

A set: a list, in order, each once.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

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

What may fail: { "ok": T } or { "err": E }.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl<T: Schema, const N: usize> Schema for [T; N]

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl<T: Schema> Schema for BTreeMap<String, T>

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl<T: Schema> Schema for Box<T>

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn absent() -> Option<Self>

Source§

fn skip(&self) -> bool

Source§

impl<T: Schema> Schema for Box<[T]>

A list that won’t change: no spare capacity.

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

impl<T: Schema> Schema for HashMap<String, T>

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

impl<T: Schema> Schema for Option<T>

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Source§

fn absent() -> Option<Self>

Source§

fn skip(&self) -> bool

Source§

impl<T: Schema> Schema for Vec<T>

Source§

fn shape() -> Shape

Source§

fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>

Source§

fn write(&self) -> Value

Source§

fn encode(&self, w: &mut Writer)

Source§

fn decode(d: &mut Decoder<'_>) -> Option<Self>

Source§

fn pack(&self, p: &mut Packer)

Source§

fn unpack(u: &mut Unpacker<'_>) -> Option<Self>

Implementors§

Source§

impl Schema for AnyRefOrTag

Source§

impl Schema for Atom

Text everywhere but in a frame, which carries its number.

Source§

impl Schema for Color

Source§

impl Schema for Diagnostic

Source§

impl Schema for Image

Source§

impl Schema for Path

A path as its steps.

Source§

impl Schema for Ref

Source§

impl Schema for Res

Source§

impl Schema for Seg

Source§

impl Schema for Severity

Source§

impl Schema for Text

Source§

impl Schema for Value

Source§

impl<K: Kind> Schema for Id<K>

Source§

impl<K: Kind> Schema for OneOrTag<K>

Source§

impl<K: Kind> Schema for TagId<K>

Source§

impl<T: Schema> Schema for OneOrList<T>

Source§

impl<T: Schema> Schema for Ordered<T>

Source§

impl<T: Schema> Schema for Stream<T>