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§
Provided Methods§
Sourcefn absent() -> Option<Self>
fn absent() -> Option<Self>
The value of a field that isn’t there — None: the field is required.
Sourcefn encode(&self, w: &mut Writer)
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).
Sourcefn decode(d: &mut Decoder<'_>) -> Option<Self>
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).
Sourcefn pack(&self, p: &mut Packer)
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).
Sourcefn unpack(u: &mut Unpacker<'_>) -> Option<Self>
fn unpack(u: &mut Unpacker<'_>) -> Option<Self>
Reads itself out of a frame; None if the bytes aren’t what
Schema::pack writes.
Sourcefn pack_list(items: &[Self], p: &mut Packer)
fn pack_list(items: &[Self], p: &mut Packer)
A list of these packed: a count, then each one (floats raw).
Sourcefn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>
fn unpack_list(u: &mut Unpacker<'_>) -> Option<Vec<Self>>
A list of these out of a frame.
Sourcefn encode_list(items: &[Self], w: &mut Writer)
fn encode_list(items: &[Self], w: &mut Writer)
A list of these written straight (numbers pack theirs).
Sourcefn decode_list(d: &mut Decoder<'_>) -> Option<Vec<Self>>
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 Arc<str>
A string shared without copying.
impl Schema for Arc<str>
A string shared without copying.
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
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.
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.
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl Schema for Cow<'static, str>
Text that may be a constant: borrowed where it’s written, owned once read.
impl Schema for Cow<'static, str>
Text that may be a constant: borrowed where it’s written, owned once read.
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl Schema for PathBuf
A file’s path, as text (a path that isn’t Unicode loses what isn’t).
impl Schema for PathBuf
A file’s path, as text (a path that isn’t Unicode loses what isn’t).
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl Schema for String
impl Schema for String
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl Schema for bool
impl Schema for bool
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl Schema for f32
impl Schema for f32
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
fn encode(&self, w: &mut Writer)
fn decode(d: &mut Decoder<'_>) -> Option<Self>
fn encode_list(items: &[Self], w: &mut Writer)
fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<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>>
Source§impl Schema for f64
impl Schema for f64
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
fn encode(&self, w: &mut Writer)
fn decode(d: &mut Decoder<'_>) -> Option<Self>
fn encode_list(items: &[Self], w: &mut Writer)
fn decode_list(d: &mut Decoder<'_>) -> Option<Vec<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>>
Source§impl Schema for i8
impl Schema for i8
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for i16
impl Schema for i16
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for i32
impl Schema for i32
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for i64
impl Schema for i64
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for u8
impl Schema for u8
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for u16
impl Schema for u16
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for u32
impl Schema for u32
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for u64
impl Schema for u64
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl Schema for usize
impl Schema for usize
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>>
Source§impl<T: Schema, E: Schema> Schema for Result<T, E>
What may fail: { "ok": T } or { "err": E }.
impl<T: Schema, E: Schema> Schema for Result<T, E>
What may fail: { "ok": T } or { "err": E }.
Source§impl<T: Schema, const N: usize> Schema for [T; N]
impl<T: Schema, const N: usize> Schema for [T; N]
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl<T: Schema> Schema for Box<T>
impl<T: Schema> Schema for Box<T>
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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 absent() -> Option<Self>
fn skip(&self) -> bool
Source§impl<T: Schema> Schema for Box<[T]>
A list that won’t change: no spare capacity.
impl<T: Schema> Schema for Box<[T]>
A list that won’t change: no spare capacity.
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Source§impl<T: Schema> Schema for Option<T>
impl<T: Schema> Schema for Option<T>
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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 absent() -> Option<Self>
fn skip(&self) -> bool
Source§impl<T: Schema> Schema for Vec<T>
impl<T: Schema> Schema for Vec<T>
fn shape() -> Shape
fn read(v: &ValueRef<'_>, cx: &mut Reader<'_>) -> Option<Self>
fn write(&self) -> Value
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>
Implementors§
impl Schema for AnyRefOrTag
impl Schema for Atom
Text everywhere but in a frame, which carries its number.
impl Schema for Color
impl Schema for Diagnostic
impl Schema for Image
impl Schema for Path
A path as its steps.