Struct quartz_nbt::NbtList [−][src]
#[repr(transparent)]pub struct NbtList(_);
Expand description
The NBT tag list type which is essentially just a wrapper for a vec of NBT tags.
This type will implement both Serialize
and Deserialize
when the serde feature is enabled,
however this type should still be read and written with the utilities in the io
module when
possible if speed is the main priority. See NbtTag
for more details.
Implementations
Returns a mutable reference to the internal vector of this NBT list.
Returns the internal vector of this NBT list.
Returns a new NBT tag list with the given initial capacity.
pub fn clone_from<'a, T, L>(list: L) -> Self where
T: Clone + Into<NbtTag> + 'a,
L: IntoIterator<Item = &'a T>,
pub fn clone_from<'a, T, L>(list: L) -> Self where
T: Clone + Into<NbtTag> + 'a,
L: IntoIterator<Item = &'a T>,
pub fn clone_repr_from<'a, T, L>(list: L) -> Self where
T: NbtRepr + 'a,
L: IntoIterator<Item = &'a T>,
pub fn clone_repr_from<'a, T, L>(list: L) -> Self where
T: NbtRepr + 'a,
L: IntoIterator<Item = &'a T>,
Creates an NbtList
of NbtCompound
s by mapping each element in the given list to its
NBT representation.
Iterates over this tag list, converting each tag reference into the specified type.
Examples
let mut list = NbtList::new(); list.push(0i32); list.push(1i32); list.push(2.0f64); let mut iter = list.iter_map::<i32>(); assert!(matches!(iter.next(), Some(Ok(0i32)))); assert!(matches!(iter.next(), Some(Ok(1i32)))); assert!(matches!(iter.next(), Some(Err(..)))); // Type mismatch assert!(iter.next().is_none());
Iterates over mutable references to the tags in this list, converting each tag reference into
the specified type. See iter_map
for usage details.
Returns true if this tag list has a length of zero, false otherwise.
Returns the value of the tag at the given index, or an error if the index is out of bounds or the the tag type does not match the type specified. This method should be used for obtaining primitives and shared references to lists and compounds.
let mut list = NbtList::clone_from(&vec![1i32, 2, 3]); assert!(matches!(list.get::<i32>(0), Ok(1))); assert!(list.get::<f64>(0).is_err()); // Type mismatch assert!(list.get::<i32>(10).is_err()); // Invalid index
Returns a mutable reference to the tag at the given index, or an error if the index is out of bounds or tag type does not match the type specified. This method should be used for obtaining mutable references to elements.
let mut list = NbtList::clone_from(&vec![1i32, 2, 3]); *list.get_mut::<&mut i32>(0).unwrap() += 1; assert!(matches!(list.get::<i32>(0), Ok(2))); assert!(list.get::<f64>(0).is_err()); // Type mismatch assert!(list.get::<i32>(10).is_err()); // Invalid index
Pushes the given value to the back of the list after wrapping it in an NbtTag
.
let mut list = NbtList::new(); list.push(10i32); assert!(matches!(list.get::<i32>(0), Ok(10))); assert!(list.get::<f64>(0).is_err()); // Type mismatch assert!(list.get::<i32>(10).is_err()); // Invalid index
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NbtList
impl UnwindSafe for NbtList
Blanket Implementations
Mutably borrows from an owned value. Read more