Expand description
This module makes it easier to use egglog from Rust.
use egglog::prelude::*;Common entry points:
rule/rust_rule— add rules whose RHS is egglog code or a Rust closure (the closure receives ancrate::WriteState).query— run a one-shot query and read out matches.BaseSort/ContainerSort— declare custom sort types.crate::PurePrim/crate::WritePrim/crate::ReadPrim/crate::FullPrim— register custom primitives via the matchingEGraph::add_*_primitivemethod.- The
add_primitive!/add_primitive_with_validator!/add_literal_prim!macros (re-exported viaegglog::*) cover the simple “pure native function” case.
Re-exports§
pub use egglog::ast::Action;pub use egglog::ast::Fact;pub use egglog::ast::Facts;pub use egglog::sort::BigIntSort;pub use egglog::sort::BigRatSort;pub use egglog::sort::BoolSort;pub use egglog::sort::F64Sort;pub use egglog::sort::I64Sort;pub use egglog::sort::StringSort;pub use egglog::sort::UnitSort;pub use egglog::CommandMacro;pub use egglog::CommandMacroRegistry;pub use egglog::Core;pub use egglog::FullState;pub use egglog::PureState;pub use egglog::Read;pub use egglog::ReadState;pub use egglog::Write;pub use egglog::WriteState;pub use egglog::EGraph;pub use egglog::sort;pub use egglog::sort;
Modules§
Macros§
Structs§
- Generic
Actions - Query
Result - The result of a query.
- Rust
Span
Enums§
Traits§
- Base
Sort - A “default” implementation of
Sortfor simple types which just want to put some data in the e-graph. If you implement this trait, do not implementSortorContainerSort. Useadd_base_sortto register base sorts with theEGraph. SeeSortfor documentation of the methods. Do not overrideto_arcsort`. - Container
Sort - A “default” implementation of
Sortfor types which just want to store a pure data structure in the e-graph. If you implement this trait, do not implementSortorBaseSort. Useadd_container_sortto register container sorts with theEGraph. SeeSortfor documentation of the methods. Do not overrideto_arcsort. - Literal
Convertible - Trait for types that can be converted to/from Literal for use in validated primitives. This enables automatic validator generation for literal primitives.
Functions§
- add_
base_ sort - Add a
BaseSortto the e-graph - add_
constructor - Declare a new constructor table.
- add_
container_ sort - add_
function - Declare a new function table.
- add_
relation - Declare a new relation table.
- add_
ruleset - Create a new ruleset.
- add_
sort - Declare a new sort.
- query
- Run a query over the database.
- rule
- Add a rule to the e-graph whose right-hand side is made up of actions.
- run_
ruleset - Run one iteration of a ruleset.
- rust_
rule - Add a rule to the e-graph whose right-hand side is a Rust callback.
- rust_
rule_ full - Like
rust_rule, but the action callback receives aFullState— it can read tables (ctx.lookup) in addition to writing them. Action callbacks ofFullPrimare only valid inContext::Full, so this helper marks the generated rule:naive: the body matches against the entire database every iteration instead of using the seminaive delta. Use this when the action genuinely needs to look up rows; preferrust_rulewhen the data can be bound via the matcher in the rule body.