Enum fastnbt::Value[][src]

pub enum Value {
    Integral(i64),
    Double(f64),
    Float(f32),
    IntegralArray(Vec<i64>),
    String(String),
    List(Vec<Value>),
    Compound(HashMap<String, Value>),
}
Expand description

Value is a complete NBT value. It owns it’s data. The Byte, Short, Int and Long NBT types are all deserialized into i64. Compounds and Lists are resursively deserialized.

    let compound: HashMap<String, Value> = fastnbt::de::from_bytes(buf.as_slice())?;
    match compound["DataVersion"] {
        Value::Integral(ver) => println!("Version: {}", ver),
        _ => {},
    }
    println!("{:#?}", compound);

Variants

Integral(i64)

Any integral value, ie a byte, short, int and long all deserialize to this type. This simplifies both usage and implementation. If you care about the exact integral type you may need to write a custom Deserialise type with serde. Please also open an issue with your use case!

Double(f64)

A double. serde distinguishes between f32 and f64, so we do too.

Float(f32)

A float. serde distinguishes between f32 and f64, so we do too.

IntegralArray(Vec<i64>)

An array of i64. This will either have been a ByteArray, IntArray or LongArray in the original NBT.

String(String)

A unicode string.

List(Vec<Value>)

A List of NBT values. Each value may have a different structure/type.

Compound(HashMap<String, Value>)

A compound, which is a struct-like object.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.