pub struct SessionContext {
pub actor: Option<SessionActor>,
pub correlation_id: Option<String>,
pub client: SessionClientContext,
pub attributes: BTreeMap<String, String>,
}Expand description
Immutable metadata describing the caller and environment for a session operation.
This type is transport-agnostic by design. Adapters may derive values from HTTP requests, RPC metadata, CLI invocations, or background jobs before passing them into session services.
§Examples
use webgates_sessions::context::{SessionActor, SessionClientContext, SessionContext};
let context = SessionContext::new()
.with_actor(SessionActor::Subject {
subject_id: "user-42".to_string(),
})
.with_correlation_id("req-abc-123")
.with_client(
SessionClientContext::new()
.with_ip_address("203.0.113.5")
.with_user_agent("MyApp/2.0"),
)
.with_attribute("entrypoint", "login");
assert!(!context.is_empty());Fields§
§actor: Option<SessionActor>Stable identifier for the logical actor that initiated the operation.
correlation_id: Option<String>Correlation identifier used to trace a session workflow across layers.
client: SessionClientContextClient environment metadata collected at the boundary.
attributes: BTreeMap<String, String>Additional non-sensitive attributes associated with the operation.
Implementations§
Source§impl SessionContext
impl SessionContext
Sourcepub fn with_actor(self, actor: SessionActor) -> Self
pub fn with_actor(self, actor: SessionActor) -> Self
Sets the actor that initiated the session operation.
Sourcepub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
pub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
Sets the correlation identifier for the current workflow.
Sourcepub fn with_client(self, client: SessionClientContext) -> Self
pub fn with_client(self, client: SessionClientContext) -> Self
Replaces the client metadata associated with the current workflow.
Trait Implementations§
Source§impl Clone for SessionContext
impl Clone for SessionContext
Source§fn clone(&self) -> SessionContext
fn clone(&self) -> SessionContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionContext
impl Debug for SessionContext
Source§impl Default for SessionContext
impl Default for SessionContext
Source§fn default() -> SessionContext
fn default() -> SessionContext
Returns the “default value” for a type. Read more
Source§impl PartialEq for SessionContext
impl PartialEq for SessionContext
Source§fn eq(&self, other: &SessionContext) -> bool
fn eq(&self, other: &SessionContext) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Eq for SessionContext
impl StructuralPartialEq for SessionContext
Auto Trait Implementations§
impl Freeze for SessionContext
impl RefUnwindSafe for SessionContext
impl Send for SessionContext
impl Sync for SessionContext
impl Unpin for SessionContext
impl UnsafeUnpin for SessionContext
impl UnwindSafe for SessionContext
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
Mutably borrows from an owned value. Read more