pub struct Justification {
pub fact_handle: FactHandle,
pub justification_type: JustificationType,
pub source_rule: Option<String>,
pub premise_facts: Vec<FactHandle>,
pub created_at: Instant,
pub id: u64,
}Expand description
Justification records WHY a fact exists
A fact can have multiple justifications (multiple rules can derive the same fact). The fact is only retracted when ALL justifications are removed.
Fields§
§fact_handle: FactHandleThe fact being justified
justification_type: JustificationTypeType of justification
source_rule: Option<String>Rule that created this fact (if logical)
premise_facts: Vec<FactHandle>Premise facts that caused this derivation If any of these are retracted, this justification is invalid
created_at: InstantWhen this justification was created
id: u64Unique ID for this justification
Implementations§
Source§impl Justification
impl Justification
Sourcepub fn explicit(fact_handle: FactHandle, id: u64) -> Self
pub fn explicit(fact_handle: FactHandle, id: u64) -> Self
Create a new explicit justification (user asserted)
Sourcepub fn logical(
fact_handle: FactHandle,
source_rule: String,
premise_facts: Vec<FactHandle>,
id: u64,
) -> Self
pub fn logical( fact_handle: FactHandle, source_rule: String, premise_facts: Vec<FactHandle>, id: u64, ) -> Self
Create a new logical justification (rule derived)
Sourcepub fn is_valid(&self, retracted_facts: &HashSet<FactHandle>) -> bool
pub fn is_valid(&self, retracted_facts: &HashSet<FactHandle>) -> bool
Check if this justification is still valid (all premise facts still exist)
Trait Implementations§
Source§impl Clone for Justification
impl Clone for Justification
Source§fn clone(&self) -> Justification
fn clone(&self) -> Justification
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Justification
impl RefUnwindSafe for Justification
impl Send for Justification
impl Sync for Justification
impl Unpin for Justification
impl UnwindSafe for Justification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more