Struct valence_nbt::compound::Compound

source ·
pub struct Compound<S = String> { /* private fields */ }
Expand description

A map type with String keys and Value values.

Implementations§

source§

impl<S> Compound<S>

source

pub fn new() -> Self

source

pub fn with_capacity(cap: usize) -> Self

source

pub fn clear(&mut self)

source§

impl<S> Compound<S>
where S: Ord + Hash,

source

pub fn get<Q>(&self, k: &Q) -> Option<&Value<S>>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn contains_key<Q>(&self, k: &Q) -> bool
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut Value<S>>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&S, &Value<S>)>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn insert<K, V>(&mut self, k: K, v: V) -> Option<Value<S>>
where K: Into<S>, V: Into<Value<S>>,

source

pub fn remove<Q>(&mut self, k: &Q) -> Option<Value<S>>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn swap_remove<Q>(&mut self, k: &Q) -> Option<Value<S>>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn shift_remove<Q>(&mut self, k: &Q) -> Option<Value<S>>
where Q: ?Sized + AsBorrowed<S>, <Q as AsBorrowed<S>>::Borrowed: Hash + Ord, S: Borrow<<Q as AsBorrowed<S>>::Borrowed>,

source

pub fn remove_entry<Q>(&mut self, k: &Q) -> Option<(S, Value<S>)>
where S: Borrow<Q>, Q: ?Sized + Ord + Hash,

source

pub fn swap_remove_entry<Q>(&mut self, k: &Q) -> Option<(S, Value<S>)>
where S: Borrow<Q>, Q: ?Sized + Ord + Hash,

source

pub fn shift_remove_entry<Q>(&mut self, k: &Q) -> Option<(S, Value<S>)>
where S: Borrow<Q>, Q: ?Sized + Ord + Hash,

source

pub fn append(&mut self, other: &mut Self)

source

pub fn entry<K>(&mut self, k: K) -> Entry<'_, S>
where K: Into<S>,

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

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

source

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

source

pub fn keys(&self) -> Keys<'_, S>

source

pub fn values(&self) -> Values<'_, S>

source

pub fn values_mut(&mut self) -> ValuesMut<'_, S>

source

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

source

pub fn merge(&mut self, other: Compound<S>)

Inserts all items from other into self recursively.

§Example
use valence_nbt::compound;

let mut this = compound! {
    "foo" => 10,
    "bar" => compound! {
        "baz" => 20,
    }
};

let other = compound! {
    "foo" => 15,
    "bar" => compound! {
        "quux" => "hello",
    }
};

this.merge(other);

assert_eq!(
    this,
    compound! {
        "foo" => 15,
        "bar" => compound! {
            "baz" => 20,
            "quux" => "hello",
        }
    }
);

Trait Implementations§

source§

impl<S: Clone> Clone for Compound<S>

source§

fn clone(&self) -> Compound<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 Compound<S>

source§

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

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

impl<S: Default> Default for Compound<S>

source§

fn default() -> Compound<S>

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

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

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 Compound

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<S> Extend<(S, Value<S>)> for Compound<S>
where S: Ord + Hash,

source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = (S, Value<S>)>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl<S> From<Compound<S>> for Value<S>

source§

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

Converts to this type from the input type.
source§

impl<S> FromIterator<(S, Value<S>)> for Compound<S>
where S: Ord + Hash,

source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = (S, Value<S>)>,

Creates a value from an iterator. Read more
source§

impl<S, Q> Index<&Q> for Compound<S>
where S: Borrow<Q> + Ord + Hash, Q: ?Sized + Ord + Hash,

source§

type Output = Value<S>

The returned type after indexing.
source§

fn index(&self, index: &Q) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<S, Q> IndexMut<&Q> for Compound<S>
where S: Borrow<Q> + Hash + Ord, Q: ?Sized + Ord + Hash,

source§

fn index_mut(&mut self, index: &Q) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

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

source§

type Deserializer = Compound

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 Compound<S>

source§

type Item = (&'a S, &'a Value<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 Compound<S>

source§

type Item = (&'a S, &'a mut Value<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 Compound<S>

source§

type Item = (S, 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 Compound<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 Compound<Str>
where Str: Ord + Hash + Serialize,

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 Compound<S>

§

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

§

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

§

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

§

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

§

impl<S> UnwindSafe for Compound<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>,