pub trait SessionHook: Send + Sync {
// Provided methods
fn on_parse(&self, _ctx: &ParseContext<'_>) -> HookOutcome { ... }
fn on_analyze(&self, _ctx: &AnalyzeContext<'_>) -> HookOutcome { ... }
fn on_plan(&self, _ctx: &PlanContext<'_>) -> HookOutcome { ... }
fn on_execute_start(&self, _ctx: &ExecuteContext<'_>) -> HookOutcome { ... }
fn on_execute_end(&self, _ctx: &ExecuteContext<'_>, _metrics: &QueryMetrics) { ... }
fn before_commit(&self, _ctx: &CommitContext<'_>) -> HookOutcome { ... }
fn after_commit(&self, _ctx: &CommitContext<'_>) { ... }
fn on_abort(&self, _ctx: &AbortContext<'_>) { ... }
}Expand description
Session-lifecycle hook plugin.
Every method has a default that does nothing; implementations override
only the phases they need. Phased dispatch lets a hook plugin perform
audit at on_execute_end without paying parse-time cost, etc.
Provided Methods§
Sourcefn on_parse(&self, _ctx: &ParseContext<'_>) -> HookOutcome
fn on_parse(&self, _ctx: &ParseContext<'_>) -> HookOutcome
Called after the query source is parsed; the hook may reject parse failures or annotate the parse for downstream phases.
Sourcefn on_analyze(&self, _ctx: &AnalyzeContext<'_>) -> HookOutcome
fn on_analyze(&self, _ctx: &AnalyzeContext<'_>) -> HookOutcome
Called after semantic analysis. Useful for row-level security predicate injection.
Sourcefn on_plan(&self, _ctx: &PlanContext<'_>) -> HookOutcome
fn on_plan(&self, _ctx: &PlanContext<'_>) -> HookOutcome
Called after logical planning; the hook may rewrite the plan.
Sourcefn on_execute_start(&self, _ctx: &ExecuteContext<'_>) -> HookOutcome
fn on_execute_start(&self, _ctx: &ExecuteContext<'_>) -> HookOutcome
Called immediately before physical execution begins.
Sourcefn on_execute_end(&self, _ctx: &ExecuteContext<'_>, _metrics: &QueryMetrics)
fn on_execute_end(&self, _ctx: &ExecuteContext<'_>, _metrics: &QueryMetrics)
Called once execution finishes with the collected metrics.
Sourcefn before_commit(&self, _ctx: &CommitContext<'_>) -> HookOutcome
fn before_commit(&self, _ctx: &CommitContext<'_>) -> HookOutcome
Called before commit; may reject the transaction.
Sourcefn after_commit(&self, _ctx: &CommitContext<'_>)
fn after_commit(&self, _ctx: &CommitContext<'_>)
Called after a successful commit.
Sourcefn on_abort(&self, _ctx: &AbortContext<'_>)
fn on_abort(&self, _ctx: &AbortContext<'_>)
Called when a transaction aborts (by rollback or error).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".