Enum valence_nbt::list::List

source ·
pub enum List<S = String> {
Show 13 variants End, Byte(Vec<i8>), Short(Vec<i16>), Int(Vec<i32>), Long(Vec<i64>), Float(Vec<f32>), Double(Vec<f64>), ByteArray(Vec<Vec<i8>>), String(Vec<S>), List(Vec<List<S>>), Compound(Vec<Compound<S>>), IntArray(Vec<Vec<i32>>), LongArray(Vec<Vec<i64>>),
}
Expand description

An NBT list value.

NBT lists are homogeneous, meaning each list element must be of the same type. This is opposed to a format like JSON where lists can be heterogeneous. Here is a JSON list that would be illegal in NBT:

[42, "hello", {}]

Every possible element type has its own variant in this enum. As a result, heterogeneous lists are unrepresentable.

Variants§

§

End

The list with the element type of TAG_End and length of zero.

§

Byte(Vec<i8>)

§

Short(Vec<i16>)

§

Int(Vec<i32>)

§

Long(Vec<i64>)

§

Float(Vec<f32>)

§

Double(Vec<f64>)

§

ByteArray(Vec<Vec<i8>>)

§

String(Vec<S>)

§

List(Vec<List<S>>)

§

Compound(Vec<Compound<S>>)

§

IntArray(Vec<Vec<i32>>)

§

LongArray(Vec<Vec<i64>>)

Implementations§

source§

impl<S> List<S>

source

pub fn new() -> Self

Constructs a new empty NBT list, with the element type of TAG_End.

source

pub fn len(&self) -> usize

Returns the length of this list.

source

pub fn is_empty(&self) -> bool

Returns true if this list has no elements. false otherwise.

source

pub fn element_tag(&self) -> Tag

Returns the element type of this list.

source

pub fn get(&self, index: usize) -> Option<ValueRef<'_, S>>

Gets a reference to the value at the given index in this list, or None if the index is out of bounds.

source

pub fn get_mut(&mut self, index: usize) -> Option<ValueMut<'_, S>>

Gets a mutable reference to the value at the given index in this list, or None if the index is out of bounds.

source

pub fn try_push<V: Into<Value<S>>>(&mut self, value: V) -> bool

Attempts to add the given value to the end of this list, failing if adding the value would result in the list not being heterogeneous (have multiple types inside it). Returns true if the value was added, false otherwise.

source

pub fn try_insert<V: Into<Value<S>>>(&mut self, index: usize, value: V) -> bool

Attempts to insert the given value at the given index in this list, failing if adding the value would result in the list not being heterogeneous (have multiple types inside it). Returns true if the value was added, false otherwise.

§Panics

Panics if the index is greater than the length of the list.

source

pub fn remove(&mut self, index: usize) -> Value<S>

Removes the element at the given index in the list, and returns the value removed.

§Panics

Panics if index is out of bounds.

source

pub fn retain<F>(&mut self, f: F)
where F: FnMut(ValueMut<'_, S>) -> bool,

Returns only the elements specified by the predicate, passing a mutable reference to it.

In other words, removes all elements e such that f(ValueMut(&mut e)) returns false. This method operates in place, visiting each element exactly once in the original order, and preserves the order of the retained elements.

source

pub fn iter(&self) -> Iter<'_, S>

Returns an iterator over this list. This iterator yields ValueRefs.

source

pub fn iter_mut(&mut self) -> IterMut<'_, S>

Returns a mutable iterator over this list. This iterator yields ValueMuts.

Trait Implementations§

source§

impl<S: Clone> Clone for List<S>

source§

fn clone(&self) -> List<S>

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<S: Debug> Debug for List<S>

source§

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

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

impl<S> Default for List<S>

source§

fn default() -> List<S>

Returns the “default value” for a type. Read more
source§

impl<'de, S> Deserialize<'de> for List<S>
where S: Deserialize<'de> + Ord + Hash,

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'de> Deserializer<'de> for List

source§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
source§

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
source§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
source§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
source§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
source§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
source§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
source§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
source§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
source§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
source§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
source§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
source§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
source§

fn deserialize_char<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
source§

fn deserialize_str<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
source§

fn deserialize_option<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
source§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
source§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
source§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
source§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
source§

fn deserialize_map<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
source§

fn deserialize_struct<V>( self, name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
source§

fn deserialize_enum<V>( self, name: &'static str, variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<V::Value, <Self as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
source§

impl<'a, S> From<&'a List<S>> for ValueRef<'a, S>

source§

fn from(v: &'a List<S>) -> Self

Converts to this type from the input type.
source§

impl<'a, S> From<&'a mut List<S>> for ValueMut<'a, S>

source§

fn from(v: &'a mut List<S>) -> Self

Converts to this type from the input type.
source§

impl<S> From<List<S>> for Value<S>

source§

fn from(v: List<S>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Value<S>> for List<S>

Converts a value to a singleton list.

source§

fn from(value: Value<S>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<Compound<S>>> for List<S>

source§

fn from(v: Vec<Compound<S>>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Vec<Cow<'a, JavaStr>>> for List<Cow<'a, JavaStr>>

source§

fn from(v: Vec<Cow<'a, JavaStr>>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<Vec<Cow<'a, str>>> for List<Cow<'a, str>>

source§

fn from(v: Vec<Cow<'a, str>>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<JavaString>> for List<JavaString>

source§

fn from(v: Vec<JavaString>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<List<S>>> for List<S>

source§

fn from(v: Vec<List<S>>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<String>> for List<String>

source§

fn from(v: Vec<String>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<Vec<i32>>> for List<S>

source§

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

Converts to this type from the input type.
source§

impl<S> From<Vec<Vec<i64>>> for List<S>

source§

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

Converts to this type from the input type.
source§

impl<S> From<Vec<Vec<i8>>> for List<S>

source§

fn from(v: Vec<Vec<i8>>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<f32>> for List<S>

source§

fn from(v: Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<f64>> for List<S>

source§

fn from(v: Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<i16>> for List<S>

source§

fn from(v: Vec<i16>) -> Self

Converts to this type from the input type.
source§

impl<S> From<Vec<i32>> for List<S>

source§

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

Converts to this type from the input type.
source§

impl<S> From<Vec<i64>> for List<S>

source§

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

Converts to this type from the input type.
source§

impl<S> From<Vec<i8>> for List<S>

source§

fn from(v: Vec<i8>) -> Self

Converts to this type from the input type.
source§

impl<'de> IntoDeserializer<'de, Error> for List

source§

type Deserializer = List

The type of the deserializer being converted into.
source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
source§

impl<'a, S> IntoIterator for &'a List<S>

source§

type Item = ValueRef<'a, S>

The type of the elements being iterated over.
source§

type IntoIter = Iter<'a, S>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, S> IntoIterator for &'a mut List<S>

source§

type Item = ValueMut<'a, S>

The type of the elements being iterated over.
source§

type IntoIter = IterMut<'a, S>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<S> IntoIterator for List<S>

source§

type Item = Value<S>

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<S>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<S> PartialEq for List<S>
where S: Ord + Hash,

source§

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

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

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

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

impl<Str> Serialize for List<Str>
where Str: Serialize + Ord + Hash,

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S> Freeze for List<S>

§

impl<S> RefUnwindSafe for List<S>
where S: RefUnwindSafe,

§

impl<S> Send for List<S>
where S: Send,

§

impl<S> Sync for List<S>
where S: Sync,

§

impl<S> Unpin for List<S>
where S: Unpin,

§

impl<S> UnwindSafe for List<S>
where S: UnwindSafe,

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, dst: *mut T)

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

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,