Enum valence_nbt::value::Value

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

Represents an arbitrary NBT value.

Variants§

§

Byte(i8)

§

Short(i16)

§

Int(i32)

§

Long(i64)

§

Float(f32)

§

Double(f64)

§

ByteArray(Vec<i8>)

§

String(S)

§

List(List<S>)

§

Compound(Compound<S>)

§

IntArray(Vec<i32>)

§

LongArray(Vec<i64>)

Implementations§

source§

impl<S> Value<S>

source

pub fn tag(&self) -> Tag

Returns the type of this value.

source

pub fn is_number(&self) -> bool

Returns whether this value is a number, i.e. a byte, short, int, long, float or double.

source

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

If this value is a number, returns the i8 representation of this value.

source

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

If this value is a number, returns the i16 representation of this value.

source

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

If this value is a number, returns the i32 representation of this value.

source

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

If this value is a number, returns the i64 representation of this value.

source

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

If this value is a number, returns the f32 representation of this value.

source

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

If this value is a number, returns the f64 representation of this value.

source

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

If this value is a number, returns the bool representation of this value.

source§

impl<S> Value<S>

source

pub fn as_value_ref(&self) -> ValueRef<'_, S>

Converts a reference to a value to a ValueRef.

source

pub fn as_value_mut(&mut self) -> ValueMut<'_, S>

Converts a mutable reference to a value to a ValueMut.

Trait Implementations§

source§

impl<S: Clone> Clone for Value<S>

source§

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

source§

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

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

impl From<&String> for Value<String>

source§

fn from(value: &String) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a String> for Value<Cow<'a, str>>

source§

fn from(v: &'a String) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl<S> From<&ValueMut<'_, S>> for Value<S>
where S: Clone,

source§

fn from(v: &ValueMut<'_, S>) -> Self

Converts to this type from the input type.
source§

impl<S> From<&ValueRef<'_, S>> for Value<S>
where S: Clone,

source§

fn from(v: &ValueRef<'_, S>) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl<'a> From<&'a str> for Value<String>

source§

fn from(v: &'a str) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a str> for Value<Cow<'a, str>>

source§

fn from(v: &'a str) -> 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<'a> From<Cow<'a, str>> for Value<String>

source§

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

Converts to this type from the input type.
source§

impl<'a> From<Cow<'a, str>> for Value<Cow<'a, str>>

source§

fn from(v: Cow<'a, str>) -> 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 From<String> for Value<String>

source§

fn from(v: String) -> Self

Converts to this type from the input type.
source§

impl From<String> for Value<Cow<'_, str>>

source§

fn from(v: String) -> 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<ValueMut<'_, S>> for Value<S>
where S: Clone,

source§

fn from(v: ValueMut<'_, S>) -> Self

Converts to this type from the input type.
source§

impl<S> From<ValueRef<'_, S>> for Value<S>
where S: Clone,

source§

fn from(v: ValueRef<'_, S>) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl<S> From<bool> for Value<S>

Bools are usually represented as 0 or 1 bytes in NBT.

source§

fn from(b: bool) -> Self

Converts to this type from the input type.
source§

impl<S> From<f32> for Value<S>

source§

fn from(v: f32) -> Self

Converts to this type from the input type.
source§

impl<S> From<f64> for Value<S>

source§

fn from(v: f64) -> Self

Converts to this type from the input type.
source§

impl<S> From<i16> for Value<S>

source§

fn from(v: i16) -> Self

Converts to this type from the input type.
source§

impl<S> From<i32> for Value<S>

source§

fn from(v: i32) -> Self

Converts to this type from the input type.
source§

impl<S> From<i64> for Value<S>

source§

fn from(v: i64) -> Self

Converts to this type from the input type.
source§

impl<S> From<i8> for Value<S>

source§

fn from(v: i8) -> Self

Converts to this type from the input type.
source§

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

source§

fn eq(&self, other: &Self) -> 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.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<S> UnwindSafe for Value<S>

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.