#[non_exhaustive]pub struct ObjectKey {
pub class: String,
pub keys: BTreeMap<String, KeyValue>,
}Expand description
An object as its key encoding decodes: a class name and its key tuple, by key name. Which class the name denotes, and whether the keys are that class’s, are not known here: the encoding is checked for form only (16.5), against a class by the caller.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.class: StringThe full class name, e.g. rates.example.org/fx_pair.
keys: BTreeMap<String, KeyValue>The keys by name (ascending in the encoding, as a BTreeMap iterates).
Implementations§
Source§impl ObjectKey
impl ObjectKey
Sourcepub fn new(
class: &str,
keys: impl IntoIterator<Item = (String, KeyValue)>,
) -> Result<ObjectKey>
pub fn new( class: &str, keys: impl IntoIterator<Item = (String, KeyValue)>, ) -> Result<ObjectKey>
An object of class with these keys (the pairs may come in any order: the encoding sorts
them). E_CANON_NAME for a class name that is not a full name (2.3), E_CANON_ARG_NAME
for a key name that is not an argument name (2.4), E_CANON_TYPE for a blob scalar (a
key is never a blob, 16.1), E_CANON_ARG_DUPLICATE for a key name given twice.
Sourcepub fn to_value(&self) -> Value
pub fn to_value(&self) -> Value
The decoded form the key vectors give: {"class": name, "keys": {name: <typed scalar or a nested decoded object>, ...}}.
Sourcepub fn object_value(&self, class_hash: &str) -> Result<Value>
pub fn object_value(&self, class_hash: &str) -> Result<Value>
The object JSON of 16.5, {"class", "class_hash", "keys": {name: <typed scalar>, ...}},
every key bound. class_hash is 64 lowercase hex digits (E_CANON_HEX otherwise). A
class-typed key is the typed string scalar holding its key encoding (16.5: “the object
travels as one canonical string”).
Sourcepub fn object_id(&self, class_hash: &str) -> Result<String>
pub fn object_id(&self, class_hash: &str) -> Result<String>
The object id: SHA-256 (lowercase hex) of the canonical bytes (6.2) of
object_value.
Sourcepub fn call_form(&self) -> String
pub fn call_form(&self) -> String
The object’s canonical call form (16.8): the class name and every key labelled in
ascending order, name: <literal>, separated by , : strings quoted with " doubled,
numbers, dates, instants and booleans bare, and a class-typed key (a string holding its
key encoding) quoted like any string, x: "b.example.org/m(y:1)". For example scripture.example.org/verse(book: "Gen", chapter: 1, corpus: "tanakh", verse: 1).