pub struct OperationContext {
pub xid: Option<Xid>,
pub connection_id: Option<u64>,
pub audit_principal: String,
pub request_id: String,
pub write_consent: Option<WriteConsent>,
pub tenant: Option<String>,
}Expand description
Per-request context plumbed through every port method.
Fields§
§xid: Option<Xid>MVCC snapshot id when the request opened a transaction;
None for autocommit reads/writes.
connection_id: Option<u64>Connection identifier the request arrived on; ties this context back to per-connection state (current transaction, session variables) when needed.
audit_principal: StringIdentity recorded in audit logs. "anonymous" when the
caller did not authenticate.
request_id: StringStable per-request id used for log correlation. Either
supplied by the caller via X-Request-Id or minted as a
monotonic ULID-like string at request entry.
write_consent: Option<WriteConsent>Sealed gate token, present only when WriteGate::check
granted permission. Mutating port methods demand this is
Some(...); missing it is a runtime error (and during the
migration window, a structural reminder that the call site
hasn’t been threaded yet).
tenant: Option<String>Optional tenant override. None falls back to the
connection’s default tenant.
Implementations§
Source§impl OperationContext
impl OperationContext
Sourcepub fn implicit() -> Self
pub fn implicit() -> Self
Anonymous, no-write-consent context. The default for any caller that hasn’t been migrated to construct an explicit context yet — keeps the migration window compilable.
Sourcepub fn read_only(request_id: impl Into<String>) -> Self
pub fn read_only(request_id: impl Into<String>) -> Self
Read-only context bound to a stable request id. Use when the handler knows it is dispatching a query that never mutates.
Sourcepub fn writing(consent: WriteConsent, request_id: impl Into<String>) -> Self
pub fn writing(consent: WriteConsent, request_id: impl Into<String>) -> Self
Writing context with an attached gate token. Construct
WriteConsent via WriteGate::check first; passing the
token here is the single point that proves the request
passed the policy.
pub fn with_principal(self, principal: impl Into<String>) -> Self
pub fn with_connection(self, connection_id: u64) -> Self
pub fn with_xid(self, xid: Xid) -> Self
pub fn with_tenant(self, tenant: impl Into<String>) -> Self
pub fn require_write_consent(&self) -> Result<&WriteConsent, RedDBError>
Trait Implementations§
Source§impl Clone for OperationContext
impl Clone for OperationContext
Source§fn clone(&self) -> OperationContext
fn clone(&self) -> OperationContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for OperationContext
impl RefUnwindSafe for OperationContext
impl Send for OperationContext
impl Sync for OperationContext
impl Unpin for OperationContext
impl UnsafeUnpin for OperationContext
impl UnwindSafe for OperationContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request