Enum crab_nbt::NbtTag

source ·
#[repr(u8)]
pub enum NbtTag {
Show 13 variants End = 0, Byte(i8), Short(i16), Int(i32), Long(i64), Float(f32), Double(f64), ByteArray(Bytes), String(String), List(Vec<NbtTag>), Compound(NbtCompound), IntArray(Vec<i32>), LongArray(Vec<i64>),
}
Expand description

Enum representing the different types of NBT tags. Each variant corresponds to a different type of data that can be stored in an NBT tag.

Variants§

§

End = 0

§

Byte(i8)

§

Short(i16)

§

Int(i32)

§

Long(i64)

§

Float(f32)

§

Double(f64)

§

ByteArray(Bytes)

§

String(String)

§

List(Vec<NbtTag>)

§

Compound(NbtCompound)

§

IntArray(Vec<i32>)

§

LongArray(Vec<i64>)

Implementations§

source§

impl NbtTag

source

pub const fn get_type_id(&self) -> u8

Returns the numeric id associated with the data type.

source

pub fn serialize(&self) -> Bytes

source

pub fn serialize_data(&self) -> Bytes

source

pub fn deserialize(bytes: &mut impl Buf) -> Result<NbtTag, Error>

source

pub fn deserialize_data( bytes: &mut impl Buf, tag_id: u8 ) -> Result<NbtTag, Error>

source

pub fn extract_byte(&self) -> Option<i8>

source

pub fn extract_short(&self) -> Option<i16>

source

pub fn extract_int(&self) -> Option<i32>

source

pub fn extract_long(&self) -> Option<i64>

source

pub fn extract_float(&self) -> Option<f32>

source

pub fn extract_double(&self) -> Option<f64>

source

pub fn extract_bool(&self) -> Option<bool>

source

pub fn extract_byte_array(&self) -> Option<Bytes>

source

pub fn extract_string(&self) -> Option<&String>

source

pub fn extract_list(&self) -> Option<&Vec<NbtTag>>

source

pub fn extract_compound(&self) -> Option<&NbtCompound>

source

pub fn extract_int_array(&self) -> Option<&Vec<i32>>

source

pub fn extract_long_array(&self) -> Option<&Vec<i64>>

Trait Implementations§

source§

impl Clone for NbtTag

source§

fn clone(&self) -> NbtTag

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for NbtTag

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&[u8]> for NbtTag

source§

fn from(value: &[u8]) -> Self

Converts to this type from the input type.
source§

impl From<&str> for NbtTag

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl From<Bytes> for NbtTag

source§

fn from(value: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<NbtCompound> for NbtTag

source§

fn from(value: NbtCompound) -> Self

Converts to this type from the input type.
source§

impl From<String> for NbtTag

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<NbtTag>> for NbtTag

source§

fn from(value: Vec<NbtTag>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<i32>> for NbtTag

source§

fn from(value: Vec<i32>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<i64>> for NbtTag

source§

fn from(value: Vec<i64>) -> Self

Converts to this type from the input type.
source§

impl From<bool> for NbtTag

source§

fn from(value: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for NbtTag

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for NbtTag

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i16> for NbtTag

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for NbtTag

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for NbtTag

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for NbtTag

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl PartialEq for NbtTag

source§

fn eq(&self, other: &NbtTag) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for NbtTag

Auto Trait Implementations§

§

impl !Freeze for NbtTag

§

impl RefUnwindSafe for NbtTag

§

impl Send for NbtTag

§

impl Sync for NbtTag

§

impl Unpin for NbtTag

§

impl UnwindSafe for NbtTag

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.