Skip to main content

ClassDescriptor

Struct ClassDescriptor 

Source
#[non_exhaustive]
pub struct ClassDescriptor { pub keys: BTreeMap<String, ClassKey>, pub order: Vec<String>, pub methods: BTreeMap<String, String>, pub steward: Steward, pub parent: Option<String>, pub is_final: bool, pub open: Vec<String>, pub maps: Vec<String>, pub inverse: Vec<String>, pub lookup: Option<String>, pub extent: Option<ClassExtent>, pub implements: Vec<String>, }
Expand description

A class descriptor (16.1): as an author writes it (ClassDescriptor::from_json, which checks it) or flattened (define_class); the flattened descriptor is the class descriptor, and its hash the class hash.

Optional members are absent rather than empty: an empty Vec here means the member is absent, and false for is_final.

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.
§keys: BTreeMap<String, ClassKey>

keys: the key declarations by name (at most 32).

§order: Vec<String>

order: every key name exactly once.

§methods: BTreeMap<String, String>

methods: method name to function hash.

§steward: Steward

steward.

§parent: Option<String>

parent: the class hash of the parent class.

§is_final: bool

final: true when written ("final": true).

§open: Vec<String>

open: method names overridable in a subclass of a final class; ascending, unique.

§maps: Vec<String>

maps: ontology URIs; ascending, unique.

§inverse: Vec<String>

inverse: attribute names, each with a method by_<attribute>; ascending, unique.

§lookup: Option<String>

lookup: the name of the lookup method (D93).

§extent: Option<ClassExtent>

extent.

§implements: Vec<String>

implements: class hashes of interfaces; ascending, unique.

Implementations§

Source§

impl ClassDescriptor

Source

pub fn from_json(bytes: &[u8]) -> Result<ClassDescriptor>

Parses and checks a class descriptor given as JSON text: strict JSON, then 16.1 in its check order, for what the descriptor alone decides. The structure over the whole descriptor first (E_SCHEMA: a missing required member, an unknown member, an empty array, an empty extent, final other than true), then keys (the count, then each key in JCS order of names: its name, then its declaration), order, methods (in JCS order of names), steward, parent, open, maps, inverse, lookup, extent, implements, with the codes of 16.1.

Checks that need the method functions (that a lookup method takes one label, that an extent function has the right signature) are define_class’s. A flattened descriptor (one with parent) passes as well: this is the check define makes at steps 2 and 5.

Source

pub fn from_value(v: &Value) -> Result<ClassDescriptor>

As from_json, for a parsed value.

Source

pub fn to_value(&self) -> Value

The JSON form (members absent when empty).

Source

pub fn canonical(&self) -> Vec<u8> ⓘ

The canonical bytes (6.2). Of a flattened descriptor, they are what the class hash hashes.

Source

pub fn hash(&self) -> String

The class hash: SHA-256 of the canonical bytes, lowercase hex. The class name is not part of it. Meant for a flattened descriptor (define_class’s result, or one read back with from_json).

Trait Implementations§

Source§

impl Clone for ClassDescriptor

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 ClassDescriptor

Source§

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

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

impl Eq for ClassDescriptor

Source§

impl PartialEq for ClassDescriptor

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 ClassDescriptor

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.