You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scales::Value is a lightweight container that simply holds references to a type registry and the scale encoded data, it allows using serde to for example build a serde_json::Value from the underlying encoded data to make it easy for users to interpret it. However in constrained contexts where its not desirable to have the extra serde_json or similar dependency and allocate a new object having some utility functions on Value to access fields and values can come quite handy.
// e.g. struct that that gets encoded to scalestructSomeStruct<'a>{field_a:u8,field_b:&'a str,}let value = Value::new(&encoded_some_struct, ty_id,®istry);// e.g. some way to access a fieldlet f_a = value.field("field_a")?.as_u8()?;// e.g. a method that returns an iterator of (field, value)let f_b = value.fields().filter_map(|(f, _v)| f.eq("field_b").then_some(v))?.as_str();
The text was updated successfully, but these errors were encountered:
olanod
changed the title
scales::Value data access functionsscales::Value data retrieval methods
May 2, 2024
scales::Value
is a lightweight container that simply holds references to a type registry and the scale encoded data, it allows using serde to for example build aserde_json::Value
from the underlying encoded data to make it easy for users to interpret it. However in constrained contexts where its not desirable to have the extra serde_json or similar dependency and allocate a new object having some utility functions onValue
to access fields and values can come quite handy.The text was updated successfully, but these errors were encountered: