pub enum NbtTag {
Byte(i8),
Short(i16),
Int(i32),
Long(i64),
Float(f32),
Double(f64),
ByteArray(Vec<i8>),
String(String),
List(NbtList),
Compound(NbtCompound),
IntArray(Vec<i32>),
LongArray(Vec<i64>),
}
Expand description
The generic NBT tag type, containing all supported tag variants which wrap around a corresponding
rust type.
This type will implement both Serialize
and Deserialize
when the serde feature is enabled,
however this type should still be read and written with the utilities in the io
module when
possible if speed is the main priority. When linking into the serde ecosystem, we ensured that all
tag types would have their data inlined into the result NBT output of our Serializer. Because of
this, NBT tags are only compatible with self-describing formats, and also have slower deserialization
implementations due to this restriction.
A signed, one-byte integer.
A signed, two-byte integer.
A signed, four-byte integer.
A signed, eight-byte integer.
A 32-bit floating point value.
A 64-bit floating point value.
An array (vec) of one-byte integers. Minecraft treats this as an array of signed bytes.
An array (vec) of signed, four-byte integers.
An array (vec) of signed, eight-byte integers.
Returns the single character denoting this tag’s type, or an empty string if this tag type has
no type specifier.
assert_eq!(NbtTag::Long(10).type_specifier(), "L");
assert_eq!(NbtTag::String(String::new()).type_specifier(), "");
assert_eq!(NbtTag::Int(-10).type_specifier(), "I");
Converts this NBT tag into a valid, parsable SNBT string with no extraneous spacing. This method should
not be used to generate user-facing text, rather to_component
should be used instead.
Simple primitive conversion:
assert_eq!(NbtTag::Byte(5).to_snbt(), "5B");
assert_eq!(NbtTag::String("\"Quoted text\"".to_owned()).to_snbt(), "'\"Quoted text\"'");
More complex tag conversion:
let mut compound = NbtCompound::new();
compound.insert("foo".to_owned(), vec![-1_i64, -3_i64, -5_i64]);
assert_eq!(NbtTag::Compound(compound).to_snbt(), "{foo:[L;-1,-3,-5]}");
Returns whether or not the given string needs to be quoted due to non-alphanumeric or otherwise
non-standard characters.
Wraps the given string in quotes and escapes any quotes contained in the original string.
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
Formats the value using the given formatter. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Serialize this value into the given Serde serializer. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
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
Converts the given value to a String
. Read more
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.