Skip to main content

Tag

Enum Tag 

pub enum Tag {
Show 13 variants End, Byte(i8), Short(i16), Int(i32), Long(i64), Float(u32), Double(u64), ByteArray(Vec<u8>), String(JavaString), List(Vec<Tag>), Compound(BTreeMap<JavaString, Tag>), IntArray(Vec<i32>), LongArray(Vec<i64>),
}
Expand description

Float and double variants hold their IEEE bit patterns. Java’s disk output canonicalizes NaNs (DataOutputStream.writeFloat); its network output keeps their bits (Netty’s ByteBuf.writeFloat). Loading, like vanilla’s valueOf factories, normalizes negative zero to positive zero.

Variants§

§

End

§

Byte(i8)

§

Short(i16)

§

Int(i32)

§

Long(i64)

§

Float(u32)

§

Double(u64)

§

ByteArray(Vec<u8>)

§

String(JavaString)

§

List(Vec<Tag>)

§

Compound(BTreeMap<JavaString, Tag>)

§

IntArray(Vec<i32>)

§

LongArray(Vec<i64>)

Implementations§

§

impl Tag

pub fn id(&self) -> u8

pub fn get(&self, key: &str) -> Option<&Tag>

pub fn get_mut(&mut self, key: &str) -> Option<&mut Tag>

pub fn compound( entries: impl IntoIterator<Item = (impl Into<JavaString>, Tag)>, ) -> Tag

§

impl Tag

pub fn to_network_bytes(&self) -> Result<Vec<u8>, Error>

Encode a nameless network root. End (also vanilla’s null marker) is [0]. Uses the engine’s network writer, preserving NaN bits; refuses depth over 512 and strings whose modified UTF-8 exceeds 65535 bytes. Vanilla applies heap quotas when reading, not writing.

pub fn from_network_bytes( bytes: &[u8], quota: Option<u64>, ) -> Result<(Tag, usize), Error>

Decode one nameless network root and return its consumed byte count. Trailing bytes remain unread. None uses vanilla’s 2 MiB heap quota; Some(quota) supplies a caller quota in NbtAccounter bytes, not encoded bytes. Container nesting is limited to 512. End represents vanilla null. Malformed input, quota exhaustion and excessive depth return an Error.

Trait Implementations§

§

impl Clone for Tag

§

fn clone(&self) -> Tag

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Tag

§

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

Formats the value using the given formatter. Read more
§

impl Eq for Tag

§

impl From<&BTreeMap<JavaString, Tag>> for Tag

§

fn from(compound: &BTreeMap<JavaString, Tag>) -> Tag

Converts to this type from the input type.
§

impl Hash for Tag

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for Tag

§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
§

impl StructuralPartialEq for Tag

§

impl TryFrom<&Tag> for Vec<u8>

A tag as its network NBT bytes (write_network), the form it crosses to a wasm mod in; a tag past the default limits is refused, with the reason.

§

type Error = Error

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

fn try_from(tag: &Tag) -> Result<Vec<u8>, Error>

Performs the conversion.
§

impl TryFrom<Tag> for BTreeMap<JavaString, Tag>

The compound a compound tag holds; any other tag is refused as itself.

§

type Error = Tag

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

fn try_from(tag: Tag) -> Result<BTreeMap<JavaString, Tag>, Tag>

Performs the conversion.
§

impl TryFrom<Vec<u8>> for Tag

A tag read from its network NBT bytes (read_network).

§

type Error = Error

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

fn try_from(bytes: Vec<u8>) -> Result<Tag, Error>

Performs the conversion.
§

impl Wire for Tag

§

const MIN: usize = 4

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Tag, WireError>

Decodes one value, leaving any following bytes for the caller.

Auto Trait Implementations§

§

impl Freeze for Tag

§

impl RefUnwindSafe for Tag

§

impl Send for Tag

§

impl Sync for Tag

§

impl Unpin for Tag

§

impl UnsafeUnpin for Tag

§

impl UnwindSafe for Tag

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Put for T
where T: Wire,

§

fn put_to(&self, out: &mut Writer)

Writes it.
§

impl<T> Record for T
where T: Wire,

§

fn encode(&self, out: &mut Writer)

Writes the argument into a hook call.
§

fn apply(&mut self, bytes: &[u8]) -> Result<(), WireError>

Applies one complete reply, refusing malformed or trailing bytes atomically.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.