Skip to main content

Claim

Struct Claim 

Source
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: Ref

The subject the claim is about.

§predicate: Symbol

The predicate relating subject to object.

§object: Ref

The object of the claim.

§kind: ClaimKind

How 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: Visibility

Read visibility policy for the claim.

Implementations§

Source§

impl Claim

Source

pub fn new(subject: Ref, predicate: Symbol, object: Ref) -> Self

Creates an asserted, public claim with no evidence or requirements.

Source

pub fn public(subject: Ref, predicate: Symbol, object: Ref) -> Self

Creates a public claim; alias for Claim::new.

Source

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.

Source

pub fn intern_object(store: &mut dyn DatumStore, object: Datum) -> Result<Ref>

Interns object into store and returns a content Ref to it.

Source

pub fn with_kind(self, kind: ClaimKind) -> Self

Returns the claim with its ClaimKind set.

Source

pub fn with_visibility(self, visibility: Visibility) -> Self

Returns the claim with its Visibility set.

Source

pub fn with_evidence(self, evidence: Vec<Ref>) -> Self

Returns the claim with its evidence references replaced.

Source

pub fn requiring(self, capability: CapabilityName) -> Self

Returns the claim with one required capability appended.

Source

pub fn with_requirements(self, requires: Vec<CapabilityName>) -> Self

Returns the claim with its required capabilities replaced.

Source

pub fn canonical_datum(&self) -> Datum

Returns the deterministic Datum form used to derive the content id.

Source

pub fn content_id(&self, store: &mut dyn DatumStore) -> Result<ContentId>

Interns the claim’s canonical datum and returns its content id.

Trait Implementations§

Source§

impl Clone for Claim

Source§

fn clone(&self) -> Claim

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 Claim

Source§

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

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

impl Eq for Claim

Source§

impl PartialEq for Claim

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Claim

Auto Trait Implementations§

§

impl Freeze for Claim

§

impl RefUnwindSafe for Claim

§

impl Send for Claim

§

impl Sync for Claim

§

impl Unpin for Claim

§

impl UnsafeUnpin for Claim

§

impl UnwindSafe for Claim

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.