pub enum Value {
Null,
Bool(bool),
Int(i64),
Float(f64),
Str(String),
List(Vec<Value>),
Map(Map),
Ref(Ref),
Bytes(Vec<u8>),
}Expand description
The text form has no syntax of its own for the typed values (Ref,
Bytes): they’re written as strings ("@file:images/logo.png"), so
every file stays JSON, and the schema of a field says what its string
means. The binary form keeps the type.
A Str holds a string as spelled: one that starts with @ is a
typed value’s spelling, read by the field’s schema
(crate::typed::classify), and plain text starting with @ is kept
with it doubled ("@@everyone"). Text and binary forms carry it as is;
Schema::write of a String doubles the @, its read undoes it.
Variants§
Null
Nothing.
Bool(bool)
true or false.
Int(i64)
An integer.
Float(f64)
A number with a fraction or an exponent.
Str(String)
A string, as spelled (a plain one’s leading @ doubled).
List(Vec<Value>)
A list.
Map(Map)
A map, in file order.
Ref(Ref)
@file:images/logo.png — something of some kind, by id.
Bytes(Vec<u8>)
Bytes as they are — a picture, a sound — written @bytes:<base64> as text.
Implementations§
Trait Implementations§
Source§impl Schema for Value
impl Schema for Value
Source§fn read(v: &ValueRef<'_>, _: &mut Reader<'_>) -> Option<Value>
fn read(v: &ValueRef<'_>, _: &mut Reader<'_>) -> Option<Value>
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_text(&self, w: &mut Writer)
fn write_text(&self, w: &mut Writer)
crate::text::Writer) —
Schema::write’s value as text, unless the type knows better
(derived ones do): no value tree is built on the way.Source§fn absent() -> Option<Self>
fn absent() -> Option<Self>
None: the field is required.Source§fn encode(&self, w: &mut Writer)
fn encode(&self, w: &mut Writer)
Schema::write’s
value encoded, unless the type knows better (derived ones do).Source§fn decode(d: &mut Decoder<'_>) -> Option<Self>
fn decode(d: &mut Decoder<'_>) -> Option<Self>
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)
fn pack(&self, p: &mut Packer)
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>
fn unpack(u: &mut Unpacker<'_>) -> Option<Self>
None if the bytes aren’t what
Schema::pack writes.