Skip to main content

ObjectKey

Struct ObjectKey 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§class: String

The 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

Source

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.

Source

pub fn to_value(&self) -> Value

The decoded form the key vectors give: {"class": name, "keys": {name: <typed scalar or a nested decoded object>, ...}}.

Source

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”).

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for ObjectKey

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectKey

Source§

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

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

impl Eq for ObjectKey

Source§

impl PartialEq for ObjectKey

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ObjectKey

Auto Trait Implementations§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.