pub enum Value {
}Expand description
A Yog Data value.
The text form has no syntax of its own for the typed values (Ref,
Tag, Res, Text, Image, Color): they’re written as strings
("@item:minecraft:stick"), so every file stays JSON, and the schema of
a field says which type its string is. The binary form keeps the type.
Variants§
Null
Bool(bool)
Int(i64)
Float(f64)
Str(String)
List(Vec<Value>)
Map(Map)
Ref(Ref)
@item:minecraft:stick — content of some kind, by id.
Tag(Ref)
@tag:item:minecraft:planks — a tag of content of some kind.
Res(Res)
@Strings.title — a mod resource (.yres entry).
Lang(String)
@lang:gui.done — a translation key of the game’s or a mod’s lang files.
Text(String)
Yog text: {b|bold} and {#8d6acc|color}.
Image(String)
An image source: sprite:button, mymod:gui/logo, item:minecraft:stick.
Color(u32)
0xAARRGGBB.
Bytes(Vec<u8>)
Bytes as they are — a picture, a sound — written @bytes:<base64> as text.
Implementations§
Source§impl Value
impl Value
pub fn is_null(&self) -> bool
pub fn as_bool(&self) -> Option<bool>
pub fn as_i64(&self) -> Option<i64>
pub fn as_f64(&self) -> Option<f64>
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
The string of a Str (and of the string-like typed values: Text, Image).
pub fn as_list(&self) -> Option<&[Value]>
pub fn as_map(&self) -> Option<&Map>
Trait Implementations§
Source§impl Schema for Value
impl Schema for Value
Source§fn read(v: &ValueRef<'_>, _: &mut Reader<'_>) -> Option<Self>
fn read(v: &ValueRef<'_>, _: &mut Reader<'_>) -> Option<Self>
v. Problems go to cx at its current path; None when the
value couldn’t be read (the problem is in cx).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.