[][src]Enum nobility::bin_decode::Tag

#[non_exhaustive]pub enum Tag<'a> {
    Byte(i8),
    Short(i16),
    Int(i32),
    Long(i64),
    Float(f32),
    Double(f64),
    ByteArray(&'a [u8]),
    String(NbtString<'a>),
    IntArray(IntArray<'a>),
    LongArray(LongArray<'a>),
    List(List<'a>),
    Compound(Compound<'a>),
}

Representation for all values that a tag can be.

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Byte(i8)

A small i8 integer.

Short(i16)

An i16 integer.

Int(i32)

An i32 integer.

Long(i64)

An i64 integer.

Float(f32)

An f32 number.

Double(f64)

An f64 number.

ByteArray(&'a [u8])

An array of raw bytes.

String(NbtString<'a>)

A string containing CESU-8 encoded text.

IntArray(IntArray<'a>)

An array of i32.

LongArray(LongArray<'a>)

An array of i64.

List(List<'a>)

An array which can only contain a single type. The type can be any tag, including a nested list. When lists are nested, the inner lists do not have to be the same type.

Compound(Compound<'a>)

A list of key/value pairs, creating a dictionary.

Implementations

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

pub fn tag_type(&self) -> TagType[src]

Returns the type that represents this tag.

pub fn as_string(&self) -> Option<NbtString<'a>>[src]

If this tag is a string, returns it. Otherwise, returns None. No coercion is performed.

pub fn as_byte_array(&self) -> Option<&[u8]>[src]

If this tag is a byte array, returns it. Otherwise, returns None.

pub fn as_compound(&self) -> Option<&Compound<'a>>[src]

If this tag is a Compound, returns it. Otherwise, returns None.

pub fn as_list(&self) -> Option<&List<'a>>[src]

If this tag is a List, returns it. Otherwise, returns None.

pub fn to_i64(&self) -> Option<i64>[src]

Attempts to coerce the tag to an integer. Byte, Short, Int, and Long will return a value, other tags will return None.

pub fn to_f64(&self) -> Option<f64>[src]

Attempts to coerce the tag to a f64. Byte, Short, Int, Long, Float, and Double will return a value, other tags will return None.

pub fn to_f32(&self) -> Option<f32>[src]

Attempts to coerce the tag to a f32. Byte, Short, Int, Long, Float, and Double will return a value, other tags will return None.

pub fn to_uuid_bytes(&self) -> Option<[u8; 16]>[src]

If the tag is in the 1.16+ UUID format (IntArray of length 4), returns it as big endian bytes. Otherwise, returns None.

pub fn to_uuid(&self) -> Option<Uuid>[src]

Similar to Tag::to_uuid_bytes, but returns a uuid::Uuid. Requires the uuid feature.

Trait Implementations

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

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

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

impl<'a> StructuralPartialEq for Tag<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Tag<'a>[src]

impl<'a> Send for Tag<'a>[src]

impl<'a> Sync for Tag<'a>[src]

impl<'a> Unpin for Tag<'a>[src]

impl<'a> UnwindSafe for Tag<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.