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<'_, '_>
impl RuleBuilder<'_, '_>
pub fn build_with_description(self, desc: impl Into<String>) -> RuleId
Sourcepub fn read_counter(&mut self, counter: CounterId) -> Variable
pub fn read_counter(&mut self, counter: CounterId) -> Variable
Return a variable containing the result of reading the specified counter.
Sourcepub fn lookup_or_insert(
&mut self,
table: TableId,
args: &[QueryEntry],
default_vals: &[WriteVal],
dst_col: ColumnId,
) -> Result<Variable, QueryError>
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.
Sourcepub fn lookup_with_default(
&mut self,
table: TableId,
args: &[QueryEntry],
default: QueryEntry,
dst_col: ColumnId,
) -> Result<Variable, QueryError>
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.
Sourcepub fn lookup(
&mut self,
table: TableId,
args: &[QueryEntry],
dst_col: ColumnId,
) -> Result<Variable, QueryError>
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.
Sourcepub fn insert(
&mut self,
table: TableId,
vals: &[QueryEntry],
) -> Result<(), QueryError>
pub fn insert( &mut self, table: TableId, vals: &[QueryEntry], ) -> Result<(), QueryError>
Insert the specified values into the given table.
Sourcepub fn insert_if_eq(
&mut self,
table: TableId,
l: QueryEntry,
r: QueryEntry,
vals: &[QueryEntry],
) -> Result<(), QueryError>
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.
Sourcepub fn remove(
&mut self,
table: TableId,
args: &[QueryEntry],
) -> Result<(), QueryError>
pub fn remove( &mut self, table: TableId, args: &[QueryEntry], ) -> Result<(), QueryError>
Remove the specified entry from the given table, if it is there.
Sourcepub fn call_external(
&mut self,
func: ExternalFunctionId,
args: &[QueryEntry],
) -> Result<Variable, QueryError>
pub fn call_external( &mut self, func: ExternalFunctionId, args: &[QueryEntry], ) -> Result<Variable, QueryError>
Apply the given external function to the specified arguments.
Sourcepub fn lookup_with_fallback(
&mut self,
table: TableId,
key: &[QueryEntry],
dst_col: ColumnId,
func: ExternalFunctionId,
func_args: &[QueryEntry],
) -> Result<Variable, QueryError>
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.
pub fn call_external_with_fallback( &mut self, f1: ExternalFunctionId, args1: &[QueryEntry], f2: ExternalFunctionId, args2: &[QueryEntry], ) -> Result<Variable, QueryError>
Sourcepub fn assert_eq(&mut self, l: QueryEntry, r: QueryEntry)
pub fn assert_eq(&mut self, l: QueryEntry, r: QueryEntry)
Continue execution iff the two arguments are equal.
Sourcepub fn assert_ne(
&mut self,
l: QueryEntry,
r: QueryEntry,
) -> Result<(), QueryError>
pub fn assert_ne( &mut self, l: QueryEntry, r: QueryEntry, ) -> Result<(), QueryError>
Continue execution iff the two arguments are not equal.
Sourcepub fn assert_any_ne(
&mut self,
l: &[QueryEntry],
r: &[QueryEntry],
) -> Result<(), QueryError>
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> 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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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