Enum quartz_nbt::NbtTag [−][src]
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.
Variants
Byte(i8)
A signed, one-byte integer.
Short(i16)
A signed, two-byte integer.
Int(i32)
A signed, four-byte integer.
Long(i64)
A signed, eight-byte integer.
Float(f32)
A 32-bit floating point value.
Double(f64)
A 64-bit floating point value.
An array (vec) of signed, one-byte integers.
String(String)
A UTF-8 string.
List(NbtList)
An NBT tag list.
Compound(NbtCompound)
An NBT tag compound.
An array (vec) of signed, four-byte integers.
An array (vec) of signed, eight-byte integers.
Implementations
impl NbtTag
[src]
impl NbtTag
[src]pub fn type_specifier(&self) -> &str
[src]
pub fn type_specifier(&self) -> &str
[src]Returns the single character denoting this tag’s type, or an empty string if this tag type has no type specifier.
Examples
assert_eq!(NbtTag::Long(10).type_specifier(), "L"); assert_eq!(NbtTag::String(String::new()).type_specifier(), ""); // Note that while integers do not require a type specifier, this method will still return "I" assert_eq!(NbtTag::Int(-10).type_specifier(), "I");
pub fn type_string(&self) -> &'static str
[src]
pub fn type_string(&self) -> &'static str
[src]Returns the name of each tag type
Examples
assert_eq!(NbtTag::Float(0.0f32).type_string(), "Float"); assert_eq!(NbtTag::LongArray(Vec::new()).type_string(), "Long Array");
pub fn to_snbt(&self) -> String
[src]
pub fn to_snbt(&self) -> String
[src]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.
Examples
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]}");
pub fn should_quote(string: &str) -> bool
[src]
pub fn should_quote(string: &str) -> bool
[src]Returns whether or not the given string needs to be quoted due to non-alphanumeric or otherwise non-standard characters.
pub fn string_to_snbt(string: &str) -> String
[src]
pub fn string_to_snbt(string: &str) -> String
[src]Wraps the given string in quotes and escapes any quotes contained in the original string.
Trait Implementations
impl From<NbtCompound> for NbtTag
[src]
impl From<NbtCompound> for NbtTag
[src]fn from(value: NbtCompound) -> NbtTag
[src]
fn from(value: NbtCompound) -> NbtTag
[src]Performs the conversion.
impl<'a> TryFrom<&'a NbtTag> for &'a NbtCompound
[src]
impl<'a> TryFrom<&'a NbtTag> for &'a NbtCompound
[src]impl<'a> TryFrom<&'a mut NbtTag> for &'a mut NbtCompound
[src]
impl<'a> TryFrom<&'a mut NbtTag> for &'a mut NbtCompound
[src]impl TryFrom<NbtTag> for NbtCompound
[src]
impl TryFrom<NbtTag> for NbtCompound
[src]impl StructuralPartialEq for NbtTag
[src]
Auto Trait Implementations
impl RefUnwindSafe for NbtTag
impl Send for NbtTag
impl Sync for NbtTag
impl Unpin for NbtTag
impl UnwindSafe for NbtTag
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more