Enum kiwi_schema::Value[][src]

pub enum Value<'a> {
    Bool(bool),
    Byte(u8),
    Int(i32),
    UInt(u32),
    Float(f32),
    String(String),
    Array(Vec<Value<'a>>),
    Enum(&'a str, &'a str),
    Object(&'a strHashMap<&'a str, Value<'a>>),
}

This type holds dynamic Kiwi data.

Values can represent anything in a Kiwi schema and can be converted to and from byte arrays using the corresponding Schema. Enums and field names are stored using string slices from their Schema for efficiency. This means that a Value can outlive the buffer it was parsed from but can't outlive the schema.

Variants

Methods

impl<'a> Value<'a>
[src]

A convenience method to extract the value out of a Bool. Returns false for other value kinds.

A convenience method to extract the value out of a Byte. Returns 0 for other value kinds.

A convenience method to extract the value out of an Int. Returns 0 for other value kinds.

A convenience method to extract the value out of a UInt. Returns 0 for other value kinds.

A convenience method to extract the value out of a Float. Returns 0.0 for other value kinds.

A convenience method to extract the value out of a String. Returns "" for other value kinds.

A convenience method to extract the length out of an Array. Returns 0 for other value kinds.

A convenience method to append to an Array. Does nothing for other value kinds.

A convenience method to extract a field out of an Object. Returns None for other value kinds or if the field isn't present.

A convenience method to update a field on an Object. Does nothing for other value kinds.

A convenience method to remove a field on an Object. Does nothing for other value kinds.

Decodes the type specified by type_id and schema from bytes.

Encodes this value into an array of bytes using the provided schema.

Decodes the type specified by type_id and schema from bb starting at the current index. After this function returns, the current index will be advanced by the amount of data that was successfully parsed. This is mainly useful as a helper routine for decode, which you probably want to use instead.

Decodes the field specified by field and schema from bb starting at the current index. This is used by decode_bb but may also be useful by itself.

Encodes the current value to the end of bb using the provided schema. This is mainly useful as a helper routine for encode, which you probably want to use instead.

Trait Implementations

impl<'a> Clone for Value<'a>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a> PartialEq for Value<'a>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a> Index<usize> for Value<'a>
[src]

The returned type after indexing.

A convenience method that adds support for self[index] expressions. It will panic if this value isn't an Array or if the provided index is out of bounds.

impl<'a> Debug for Value<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for Value<'a>

impl<'a> Sync for Value<'a>