pub struct Path {
pub root: PathRoot,
pub projection: Projection,
}Expand description
A rooted field traversal path through the application schema.
A Path starts at a PathRoot (a model or an enum variant) and
navigates through fields via a Projection. It is used by the query
engine to identify which field or nested field is being referenced.
§Examples
use toasty_core::stmt::Path;
use toasty_core::schema::app::ModelId;
// Path pointing to the root of model 0
let p = Path::model(ModelId::from_index(0));
assert!(p.projection.is_empty()); // no field stepsFields§
§root: PathRootWhere the path originates from.
projection: ProjectionTraversal through the fields.
Implementations§
Source§impl Path
impl Path
Sourcepub fn model(root: impl Into<ModelId>) -> Self
pub fn model(root: impl Into<ModelId>) -> Self
Creates a path rooted at a model with an identity projection (no field steps).
Sourcepub fn field(root: impl Into<ModelId>, field: usize) -> Self
pub fn field(root: impl Into<ModelId>, field: usize) -> Self
Creates a path rooted at a model that navigates to a single field by index.
Sourcepub const fn from_index(root: ModelId, index: usize) -> Self
pub const fn from_index(root: ModelId, index: usize) -> Self
Creates a path rooted at a model with a single field step (const-compatible).
Sourcepub fn from_variant(parent: Path, variant_id: VariantId) -> Self
pub fn from_variant(parent: Path, variant_id: VariantId) -> Self
Creates a path rooted at a specific enum variant.
parent is the path that navigates to the enum field. Subsequent
projection steps (appended via chain) index into the
variant’s fields using 0-based local indices. into_stmt renders
the root as a variant selection (Expr::variant) over the parent’s
expression.
Sourcepub fn chain(&mut self, other: &Self)
pub fn chain(&mut self, other: &Self)
Appends other’s traversal onto this path.
other’s root model is dropped: its steps continue from wherever
self ends. A variant selection in other is preserved — the result
selects the same variant at the same point of the traversal — so a
variant-rooted path can be chained onto a path reaching its enum from
another model.
Sourcepub fn into_stmt(self) -> Expr
pub fn into_stmt(self) -> Expr
Converts this path into an Expr that references the path’s field.
A variant root becomes an ExprVariant over the
parent path’s expression, projected by the variant-local steps. The
expression carries no variant check; the engine’s statement
normalization adds one per selection to the predicate built over it.
Sourcepub fn into_stmt_with_nesting(self, nesting: usize) -> Expr
pub fn into_stmt_with_nesting(self, nesting: usize) -> Expr
Converts this path into an Expr at the specified query nesting level.
A nesting level of 0 references the current query; 1 references its
parent. Projections and variant selections preserve this nesting level.