Skip to main content

Value

Struct Value 

Source
pub struct Value<'a> { /* private fields */ }
Expand description

A container for SCALE encoded data that can serialize types directly with the help of a type registry and without using an intermediate representation.

Implementations§

Source§

impl<'a> Value<'a>

Source

pub fn new(data: &'a [u8], ty_id: TypeId, registry: &'a Registry) -> Self

Wrap raw SCALE-encoded data as a typed value.

Source

pub fn ty(&self) -> Option<&'a TypeDef>

The underlying type definition.

Source

pub fn size(&self) -> Result<usize, Error>

Byte length of this value’s SCALE encoding.

Source

pub fn as_u8(&self) -> Option<u8>

Source

pub fn as_u16(&self) -> Option<u16>

Source

pub fn as_u32(&self) -> Option<u32>

Source

pub fn as_u64(&self) -> Option<u64>

Source

pub fn as_u128(&self) -> Option<u128>

Source

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

Source

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

Source

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

Source

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

Source

pub fn as_i128(&self) -> Option<i128>

Source

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

Source

pub fn as_char(&self) -> Option<char>

Source

pub fn as_str(&self) -> Option<&'a str>

Source

pub fn is_u8(&self) -> bool

Source

pub fn is_u16(&self) -> bool

Source

pub fn is_u32(&self) -> bool

Source

pub fn is_u64(&self) -> bool

Source

pub fn is_u128(&self) -> bool

Source

pub fn is_i8(&self) -> bool

Source

pub fn is_i16(&self) -> bool

Source

pub fn is_i32(&self) -> bool

Source

pub fn is_i64(&self) -> bool

Source

pub fn is_i128(&self) -> bool

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_char(&self) -> bool

Source

pub fn is_string(&self) -> bool

Source

pub fn is_sequence(&self) -> bool

Source

pub fn is_array(&self) -> bool

Source

pub fn is_tuple(&self) -> bool

Source

pub fn is_compact(&self) -> bool

Source

pub fn is_variant(&self) -> bool

Source

pub fn is_composite(&self) -> bool

Source

pub fn sequence_len(&self) -> Option<usize>

Source

pub fn sequence_get(&self, index: usize) -> Option<Value<'a>>

Source

pub fn sequence_iter(&self) -> Option<SeqIter<'a>>

Source

pub fn array_len(&self) -> Option<u32>

Source

pub fn array_get(&self, index: u32) -> Option<Value<'a>>

Source

pub fn field_count(&self) -> Option<usize>

Source

pub fn field_at(&self, index: usize) -> Option<Value<'a>>

Source

pub fn field(&self, name: &str) -> Option<Value<'a>>

Source

pub fn fields_iter(&self) -> Option<FieldIter<'a>>

Source

pub fn tuple_len(&self) -> Option<usize>

Source

pub fn tuple_get(&self, index: usize) -> Option<Value<'a>>

Source

pub fn tuple_iter(&self) -> Option<TupleIter<'a>>

Source

pub fn variant_index(&self) -> Option<u8>

Source

pub fn variant_name(&self) -> Option<&str>

Source

pub fn variant_data(&self) -> Option<Value<'a>>

Trait Implementations§

Source§

impl AsRef<[u8]> for Value<'_>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Value<'_>

Source§

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

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

impl Display for Value<'_>

Source§

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

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

impl Serialize for Value<'_>

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl<'reg> TryFrom<Value<'reg>> for Value

Available on crate feature json only.
Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(val: Value<'reg>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for Value<'a>

§

impl<'a> RefUnwindSafe for Value<'a>

§

impl<'a> Send for Value<'a>

§

impl<'a> Sync for Value<'a>

§

impl<'a> Unpin for Value<'a>

§

impl<'a> UnsafeUnpin for Value<'a>

§

impl<'a> UnwindSafe for Value<'a>

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, U> AsByteSlice<T> for U
where T: ToByteSlice, U: AsRef<[T]> + ?Sized,

Source§

fn as_byte_slice(&self) -> &[u8]

Source§

impl<U> AsSliceOf for U
where U: AsRef<[u8]> + ?Sized,

Source§

fn as_slice_of<T>(&self) -> Result<&[T], Error>
where T: FromByteSlice,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> JsonSchemaMaybe for T