pub struct Claim {
pub id: Option<ContentId>,
pub subject: Ref,
pub predicate: Symbol,
pub object: Ref,
pub kind: ClaimKind,
pub evidence: Vec<Ref>,
pub requires: Vec<CapabilityName>,
pub visibility: Visibility,
}Expand description
An asserted fact about a runtime subject: a subject/predicate/object
triple plus kind, evidence, required capabilities, and visibility.
The kernel defines the record and its canonical datum form; libraries supply
the claims and the FactStores that hold
them.
§Examples
let claim = Claim::new(
Ref::Symbol(Symbol::qualified("core", "List")),
Symbol::new("kind"),
Ref::Symbol(Symbol::qualified("core", "class")),
);
assert_eq!(claim.kind, ClaimKind::Asserted);
// The claim has a deterministic content datum.
let _ = claim.canonical_datum();Fields§
§id: Option<ContentId>Content id of the claim once interned; None before insertion.
subject: RefThe subject the claim is about.
predicate: SymbolThe predicate relating subject to object.
object: RefThe object of the claim.
kind: ClaimKindHow the claim was established.
evidence: Vec<Ref>Supporting references for the claim.
requires: Vec<CapabilityName>Capabilities required to see the claim under gated or private visibility.
visibility: VisibilityRead visibility policy for the claim.
Implementations§
Source§impl Claim
impl Claim
Sourcepub fn new(subject: Ref, predicate: Symbol, object: Ref) -> Self
pub fn new(subject: Ref, predicate: Symbol, object: Ref) -> Self
Creates an asserted, public claim with no evidence or requirements.
Sourcepub fn public(subject: Ref, predicate: Symbol, object: Ref) -> Self
pub fn public(subject: Ref, predicate: Symbol, object: Ref) -> Self
Creates a public claim; alias for Claim::new.
Sourcepub fn content_object(
store: &mut dyn DatumStore,
subject: Ref,
predicate: Symbol,
object: Datum,
) -> Result<Self>
pub fn content_object( store: &mut dyn DatumStore, subject: Ref, predicate: Symbol, object: Datum, ) -> Result<Self>
Builds a claim whose object is a Datum interned into store and
referenced by content.
Sourcepub fn intern_object(store: &mut dyn DatumStore, object: Datum) -> Result<Ref>
pub fn intern_object(store: &mut dyn DatumStore, object: Datum) -> Result<Ref>
Interns object into store and returns a content Ref to it.
Sourcepub fn with_visibility(self, visibility: Visibility) -> Self
pub fn with_visibility(self, visibility: Visibility) -> Self
Returns the claim with its Visibility set.
Sourcepub fn with_evidence(self, evidence: Vec<Ref>) -> Self
pub fn with_evidence(self, evidence: Vec<Ref>) -> Self
Returns the claim with its evidence references replaced.
Sourcepub fn requiring(self, capability: CapabilityName) -> Self
pub fn requiring(self, capability: CapabilityName) -> Self
Returns the claim with one required capability appended.
Sourcepub fn with_requirements(self, requires: Vec<CapabilityName>) -> Self
pub fn with_requirements(self, requires: Vec<CapabilityName>) -> Self
Returns the claim with its required capabilities replaced.
Sourcepub fn canonical_datum(&self) -> Datum
pub fn canonical_datum(&self) -> Datum
Returns the deterministic Datum form used to derive the content id.
Sourcepub fn content_id(&self, store: &mut dyn DatumStore) -> Result<ContentId>
pub fn content_id(&self, store: &mut dyn DatumStore) -> Result<ContentId>
Interns the claim’s canonical datum and returns its content id.