Expand description
Sealed trait family for Forge handler contexts.
These traits let shared helper functions accept any context type without knowing the concrete type. Three levels, each building on the previous:
HandlerContext: database access available to every handler kind.AuthenticatedContext: adds auth accessors for contexts that carry an authenticated user (queries, mutations, MCP tools).
All traits are sealed — they cannot be implemented outside forge-core. The proc macros emit the required impls automatically.
§Example
ⓘ
use forge_core::context::HandlerContext;
async fn count_rows<C: HandlerContext>(ctx: &C) -> forge_core::Result<i64> {
sqlx::query_scalar!("SELECT COUNT(*) FROM items")
.fetch_one(ctx.db())
.await
.map_err(forge_core::ForgeError::Database)
}Traits§
- Authenticated
Context - Trait for contexts that carry an authenticated user.
- Handler
Context - Base trait for all Forge handler contexts.