Crate scale_value
source ·Expand description
This crate exposes the Value
type and related subtypes, which are used as the runtime
representations of SCALE encoded data (much like serde_json::Value
is a runtime representation
of JSON data).
Value
’s can be:
- Encoded and decoded from SCALE bytes via
::scale_encode::EncodeAsType
and::scale_decode::DecodeAsType
traits (or by callingcrate::scale::decode_as_type
andcrate::scale::encode_as_type
). - Parsed to and from strings by calling
crate::stringify::from_str
andcrate::stringify::to_string
). Parsing from strings requires thefrom_string
feature to be enabled. - Serialized and deserialized via
serde
traits (for example, to and from JSON). They can also be serialized from and to other types with the relevant serde derives on. These require theserde
feature to be enabled. - Accessed ergonomically via the
At
trait.
Modules§
- Encoding and decoding SCALE bytes into a
crate::Value
. - Serializing and deserializing a
crate::Value
into/from other types via serde. - Converting a
crate::Value
to or from strings.
Macros§
- Construct a
scale_value::Value
Structs§
- This represents a sequence of boolean values, packed into bits.
- A struct representing a location to access in a
Value
. Value
holds a representation of some value that has been decoded, as well as some arbitrary context.- This represents the value of a specific variant from an enum, and contains the name of the variant, and the named/unnamed values associated with it.
Enums§
- A named or unnamed struct-like, array-like or tuple-like set of values. This is used to represent a range of composite values on their own, or as values for a specific
Variant
. - A “primitive” value (this includes strings).
- The underlying shape of a given value.
Traits§
- This trait allows indexing into
Value
s (and options ofValue
s) using theAt::at()
function. It’s a little like Rust’s::std::ops::Index
trait, but adapted so that we can return and work with optionals.