Skip to main content

Predicate

Enum Predicate 

Source
pub enum Predicate {
    All,
    Intent {
        intent_id: IntentId,
    },
    Session {
        session_id: SessionId,
    },
    AncestorOf {
        op_id: OpId,
    },
    And(Vec<Predicate>),
    Or(Vec<Predicate>),
    Not(Box<Predicate>),
}
Expand description

A saved query over the operation log. Evaluating against an OpLog returns the matching OperationRecords.

Serialization is hand-rolled (see the impls below) to avoid the exponential serde-derive monomorphization that recursive enums trigger when other crates in the workspace also derive Serialize on rich types.

Variants§

§

All

Every op in the log. The main branch’s “history” predicate after migration is AncestorOf { op_id: <head> }, not AllAll is a different query (“show me everything in existence”, including ops not yet on any branch).

§

Intent

Ops produced under a given intent (#131).

Fields

§intent_id: IntentId
§

Session

Ops produced from a given agent session (#131). Matches if any of the intent’s session matches; today the op carries intent_id, and the session is a property of the intent. Resolution is therefore done via the crate::IntentLog passed to [evaluate_with_intents].

Fields

§session_id: SessionId
§

AncestorOf

Causal ancestry of a given op (the op itself + its parents transitively). This is what today’s named branches map to.

Fields

§op_id: OpId
§

And(Vec<Predicate>)

All-of: an op matches iff it matches every sub-predicate.

§

Or(Vec<Predicate>)

Any-of: an op matches iff it matches at least one sub-predicate.

§

Not(Box<Predicate>)

Negation. Note this requires a corpus to negate over — Not(All) is empty, Not(AncestorOf { x }) is “every op not in x’s history”. Evaluating a top-level Not falls back to scanning the whole log; nesting it under And lets the evaluator narrow the scan to the other clauses’ candidate set first.

Implementations§

Source§

impl Predicate

Source

pub fn to_value(&self) -> Value

Convert to a serde_json::Value. The shape mirrors what an internally-tagged serde derive would have produced ({"predicate": "...", ...}).

Source

pub fn from_value(v: &Value) -> Result<Self, String>

Parse from a serde_json::Value. Errors are stringly-typed because serde::de::Error would require pulling in serde derive paths we’re explicitly avoiding.

Source

pub fn to_json_string(&self) -> String

Convenience: serde_json::to_string style.

Source

pub fn from_json_str(s: &str) -> Result<Self, String>

Convenience: serde_json::from_str style.

Trait Implementations§

Source§

impl Clone for Predicate

Source§

fn clone(&self) -> Predicate

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 Predicate

Source§

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

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

impl Eq for Predicate

Source§

impl PartialEq for Predicate

Source§

fn eq(&self, other: &Predicate) -> 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 Predicate

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.