Expand description
Lifecycle hooks attached to a Table.
Register them with Table::with_hook / Table::add_hook. Before-write
hooks run ahead of set-invariant enforcement, ordered by Phase; the
firing itself lives in the table::sets write paths.
Structs§
- AfterCx
- What an after-commit hook receives.
recordis the committed row (the former contents for a delete);beforeis the row as it was before an update, andNonefor inserts and deletes. - Before
Cx - What a before-write hook receives: the record about to be written (mutable),
the write’s
WriteContextif one is in scope, and the entity-erased table. - Delete
AllCx - What a bulk-delete hook receives: the table whose whole set is being
deleted. Its
conditions()describe the set. - Delete
Cx - What a before-delete hook receives: the row id and its current contents.
- Hooks
- A table’s registered lifecycle hooks, split by placement. The before-write
bands are kept ordered by
Phase. Populated viaTable::with_hook. - Select
Cx - What a read hook receives: the table about to be read (its conditions
describe the set) and the
WriteContextin scope, if any — the same task-local a write sees, so one scope covers a request’s reads and writes.
Enums§
- Hook
- A lifecycle hook attached to a table via
Table::with_hook. Each variant carries a closure receiving exactly the references available at that stage.BeforeSave/AfterSaveare sugar that register for both insert and update. - Hook
Return - What a
before_deletehook decided. - Phase
- Ordering band for before-write hooks. Hooks run in this order (and in registration order within a band), ahead of set-invariant enforcement.
Functions§
- after_
hook - Build an
AfterFnfrom a closure. - before_
delete_ hook - Build a
BeforeDeleteFnfrom a closure. - before_
delete_ hook_ sync - Build a
BeforeDeleteFnfrom a synchronous closure over the row id and the write’s context:Okproceeds with the delete, anErrvetoes it. - before_
hook - Build a
BeforeFnfrom a closure; the bound guides closure inference. - before_
hook_ sync - Build a
BeforeFnfrom a synchronous closure over the record and the write’s context; anErrcancels the write. For callers with nothing to await, such as a script evaluated in place. - before_
hook_ sync_ cx - Build a
BeforeFnfrom a synchronous closure over the wholeBeforeCx: the record, and on an update the id and the stored row. - delete_
all_ hook - Build a
DeleteAllFnfrom a closure. - select_
hook - Build a
SelectFnfrom a closure.
Type Aliases§
- AfterFn
- An after-commit hook: side-effects on the committed row. Used for inserts, updates, and deletes.
- Before
Delete Fn - A before-delete hook: may
Errto veto, or returnHookReturn::Handledto take over (soft-delete). - Before
Fn - A before-write hook: mutate the record in place ahead of invariant
enforcement, returning
Errto cancel the write. - BoxFuture
- The future a hook returns.
- Delete
AllFn - A bulk-delete hook, before (an
Errcancels) or afterdelete_all. - Select
Fn - A read hook: an
Errrefuses the read.