Expand description
Tree mutation + read API on top of Page.
All operations are dialect-agnostic. Read-only queries accept
&rustango::sql::Pool. Write operations that require atomic
transactions (create_root, create_child, move_to,
cascade_url_path_to_descendants) open a PoolTx via
write_transaction(&tenant.pool()) and use the _tx ORM helpers.
Path generation is two-step: the materialized-path segment is the
row’s auto-assigned id, which we don’t know until after INSERT. To
avoid the brief window where path = "", every create wraps the
insert + path update in a transaction.
move_to also takes a transaction because it rewrites every row
in the moved subtree atomically.
created_at / updated_at are framework-stamped (auto_now_add
/ auto_now); callers don’t fill them.
Structs§
- NewPage
- Builder for the user-supplied fields when creating a page. Tree fields (path, depth, parent_id, sort_order) and timestamps are computed by the create_* helpers — callers don’t fill them.
Enums§
- Tree
Error - Errors from tree operations.
Functions§
- atomic_
tree - Run
finside a frameworkrustango::sql::atomicscope while letting it returnTreeError— the bridge that lets theon_commitcache-invalidation pattern reach the tree-write paths. - cascade_
url_ path_ to_ descendants - Recompute and persist
url_pathfor every descendant ofroot_pageafter its ownurl_pathchanges. - compute_
url_ path - Compute the public URL path a page is reachable at,
given its parent’s
url_path(orNonefor root) and its own slug. Maintained on every create / slug-change / move. - rebuild_
all_ url_ paths - Recompute
url_pathfor every page in the tenant from scratch. Walks all pages inpathorder so parents update before children. Useful as a one-shot recovery / backfill verb when external SQL has touchedcms_pageoutside the admin. - validate_
child_ placement - Check that the (parent_type, child_type) pairing is permitted by both handlers’ whitelists. Skipped when either type’s whitelist is empty (the convention for “no restriction”). Public to make it usable from admin form hooks and other write paths.