pub struct Ctx { /* private fields */ }Expand description
The request context handed to a facade method’s &Ctx parameter: the
authenticated caller (tenant + permissions) plus the operation coordinates and
an optional idempotency key.
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn new(principal: Principal) -> Self
pub fn new(principal: Principal) -> Self
Builds a context around principal with no request coordinates and no
idempotency key (the transport fills those in via the extractor; this
constructor is what a direct caller or a test uses).
Sourcepub fn with_request(
self,
method: impl Into<String>,
path: impl Into<String>,
idempotency_key: Option<IdempotencyKey>,
) -> Self
pub fn with_request( self, method: impl Into<String>, path: impl Into<String>, idempotency_key: Option<IdempotencyKey>, ) -> Self
Attaches the request’s method + path and an optional idempotency key — used by the extractor, and by a test that drives a handler directly.
Sourcepub fn tenant(&self) -> Option<&str>
pub fn tenant(&self) -> Option<&str>
The caller’s tenant, if any — the value a handler scopes its queries by.
None for an untenanted or anonymous caller (which must then see nothing
tenant-scoped).
Sourcepub fn scope(&self) -> Option<Scope>
pub fn scope(&self) -> Option<Scope>
The data Scope this request runs under, derived server-side from the
authenticated caller — never from the request body (OWASP API1). A caller
bound to a tenant yields Some(Scope::Tenant), so every tenant_scoped
write in the use case is constrained to that tenant automatically.
Fail-closed (SG1, ADR 0029 BOLA): a tenant-less or anonymous caller yields
None, not Scope::Global. The handler must treat None as a refusal
(the accounts/notes scope_of shape: ctx.scope().ok_or(..)?) so a
tenant-scoped command can never silently run cross-tenant. Scope::Global is
a deliberate, audited cross-tenant choice a caller writes explicitly (the
seiva:allow-global fitness-lint allowlist) — never a fallback this method
hands out.
Sourcepub fn method(&self) -> &str
pub fn method(&self) -> &str
The request method (e.g. POST), empty when built without a request.
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
The request path (e.g. /v1/catalogs), empty when built without a request.
Sourcepub fn idempotency_key(&self) -> Option<&IdempotencyKey>
pub fn idempotency_key(&self) -> Option<&IdempotencyKey>
The validated Idempotency-Key the caller sent, if any. Idempotency is
opt-in per request; absent (or malformed — see the extractor) means a plain,
non-deduplicated call.