Enum valence_nbt::value::ValueRef

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

Represents a reference to an arbitrary NBT value, where the tag is not part of the reference.

Variants§

§

Byte(&'a i8)

§

Short(&'a i16)

§

Int(&'a i32)

§

Long(&'a i64)

§

Float(&'a f32)

§

Double(&'a f64)

§

ByteArray(&'a [i8])

§

String(&'a S)

§

List(&'a List<S>)

§

Compound(&'a Compound<S>)

§

IntArray(&'a [i32])

§

LongArray(&'a [i64])

Implementations§

source§

impl<'a, S> ValueRef<'a, 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> ValueRef<'_, S>
where S: Clone,

source

pub fn to_value(&self) -> Value<S>

Clones this value reference to a new owned Value.

Trait Implementations§

source§

impl<'a, S: Clone> Clone for ValueRef<'a, S>

source§

fn clone(&self) -> ValueRef<'a, 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<'a, S: Debug> Debug for ValueRef<'a, S>

source§

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

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

impl<'a, S> From<&'a [i32]> for ValueRef<'a, S>

source§

fn from(v: &'a [i32]) -> Self

Converts to this type from the input type.
source§

impl<'a, S> From<&'a [i64]> for ValueRef<'a, S>

source§

fn from(v: &'a [i64]) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a [i8]> for ValueRef<'a>

source§

fn from(v: &'a [i8]) -> Self

Converts to this type from the input type.
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> From<&'a Ident<String>> for ValueRef<'a, String>

source§

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

Converts to this type from the input type.
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> From<&'a String> for ValueRef<'a, String>

source§

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

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<&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 f32> for ValueRef<'a, S>

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl<'a, S> From<ValueMut<'a, S>> for ValueRef<'a, S>

source§

fn from(v: ValueMut<'a, 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> PartialEq for ValueRef<'a, 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<'a, S: Copy> Copy for ValueRef<'a, S>

Auto Trait Implementations§

§

impl<'a, S> Freeze for ValueRef<'a, S>

§

impl<'a, S> RefUnwindSafe for ValueRef<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for ValueRef<'a, S>
where S: Sync,

§

impl<'a, S> Sync for ValueRef<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for ValueRef<'a, S>

§

impl<'a, S> UnwindSafe for ValueRef<'a, S>
where S: RefUnwindSafe,

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.