RuleBuilder

Struct RuleBuilder 

Source
pub struct RuleBuilder<'outer, 'a> { /* private fields */ }
Expand description

Builder for the “action” portion of the rule.

Rules can refer to the variables bound in their query to modify the database.

Implementations§

Source§

impl RuleBuilder<'_, '_>

Source

pub fn build(self) -> RuleId

Build the finished query.

Source

pub fn build_with_description(self, desc: impl Into<String>) -> RuleId

Source

pub fn read_counter(&mut self, counter: CounterId) -> Variable

Return a variable containing the result of reading the specified counter.

Source

pub fn lookup_or_insert( &mut self, table: TableId, args: &[QueryEntry], default_vals: &[WriteVal], dst_col: ColumnId, ) -> Result<Variable, QueryError>

Return a variable containing the result of looking up the specified column from the row corresponding to given keys in the given table.

If the key does not currently have a mapping in the table, the values specified by default_vals will be inserted.

Source

pub fn lookup_with_default( &mut self, table: TableId, args: &[QueryEntry], default: QueryEntry, dst_col: ColumnId, ) -> Result<Variable, QueryError>

Return a variable containing the result of looking up the specified column from the row corresponding to given keys in the given table.

If the key does not currently have a mapping in the table, the variable takes the value of default.

Source

pub fn lookup( &mut self, table: TableId, args: &[QueryEntry], dst_col: ColumnId, ) -> Result<Variable, QueryError>

Return a variable containing the result of looking up the specified column from the row corresponding to given keys in the given table.

If the key does not currently have a mapping in the table, execution of the rule is halted.

Source

pub fn insert( &mut self, table: TableId, vals: &[QueryEntry], ) -> Result<(), QueryError>

Insert the specified values into the given table.

Source

pub fn insert_if_eq( &mut self, table: TableId, l: QueryEntry, r: QueryEntry, vals: &[QueryEntry], ) -> Result<(), QueryError>

Insert the specified values into the given table if l and r are equal.

Source

pub fn remove( &mut self, table: TableId, args: &[QueryEntry], ) -> Result<(), QueryError>

Remove the specified entry from the given table, if it is there.

Source

pub fn call_external( &mut self, func: ExternalFunctionId, args: &[QueryEntry], ) -> Result<Variable, QueryError>

Apply the given external function to the specified arguments.

Source

pub fn lookup_with_fallback( &mut self, table: TableId, key: &[QueryEntry], dst_col: ColumnId, func: ExternalFunctionId, func_args: &[QueryEntry], ) -> Result<Variable, QueryError>

Look up the given key in the given table. If the lookup fails, then call the given external function with the given arguments. Bind the result to the returned variable. If the external function returns None (and the lookup fails) then the execution of the rule halts.

Source

pub fn call_external_with_fallback( &mut self, f1: ExternalFunctionId, args1: &[QueryEntry], f2: ExternalFunctionId, args2: &[QueryEntry], ) -> Result<Variable, QueryError>

Source

pub fn assert_eq(&mut self, l: QueryEntry, r: QueryEntry)

Continue execution iff the two arguments are equal.

Source

pub fn assert_ne( &mut self, l: QueryEntry, r: QueryEntry, ) -> Result<(), QueryError>

Continue execution iff the two arguments are not equal.

Source

pub fn assert_any_ne( &mut self, l: &[QueryEntry], r: &[QueryEntry], ) -> Result<(), QueryError>

Continue execution iff there is some i such that l[i] != r[i].

This is useful when doing egglog-style rebuilding.

Auto Trait Implementations§

§

impl<'outer, 'a> Freeze for RuleBuilder<'outer, 'a>

§

impl<'outer, 'a> !RefUnwindSafe for RuleBuilder<'outer, 'a>

§

impl<'outer, 'a> Send for RuleBuilder<'outer, 'a>

§

impl<'outer, 'a> Sync for RuleBuilder<'outer, 'a>

§

impl<'outer, 'a> Unpin for RuleBuilder<'outer, 'a>

§

impl<'outer, 'a> !UnwindSafe for RuleBuilder<'outer, 'a>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V