Skip to main content

Schema

Trait Schema 

Source
pub trait Schema: Sized {
    // 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 { ... }
}
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.

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 String

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for f32

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for i8

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for i32

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for u8

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for u32

Source§

fn shape() -> Shape

Source§

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

Source§

fn write(&self) -> Value

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§

impl Schema for usize

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)

A pair, written [a, b] (a point, a size).

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§

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 absent() -> Option<Self>

Source§

fn skip(&self) -> bool

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

Implementors§