#[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
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: Stewardsteward.
parent: Option<String>parent: the class hash of the parent class.
is_final: boolfinal: 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
impl ClassDescriptor
Sourcepub fn from_json(bytes: &[u8]) -> Result<ClassDescriptor>
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.
Sourcepub fn from_value(v: &Value) -> Result<ClassDescriptor>
pub fn from_value(v: &Value) -> Result<ClassDescriptor>
As from_json, for a parsed value.
Sourcepub fn canonical(&self) -> Vec<u8> ⓘ
pub fn canonical(&self) -> Vec<u8> ⓘ
The canonical bytes (6.2). Of a flattened descriptor, they are what the class hash hashes.
Sourcepub fn hash(&self) -> String
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).