pub struct SessionChange { /* private fields */ }Expand description
Session changes a handler wants applied to the response.
Returned rather than performed, so that issuing a session is visible in a handler’s return type instead of happening as a side effect somewhere in the middle of it.
Implementations§
Source§impl SessionChange
impl SessionChange
pub fn none() -> Self
Sourcepub fn set(
token: impl Into<String>,
scope: impl Into<String>,
expires: u64,
) -> Self
pub fn set( token: impl Into<String>, scope: impl Into<String>, expires: u64, ) -> Self
Issue token for scope, expiring at the given Unix timestamp.
The expiry travels to the client so it can drop the token when it lapses,
but it is not what enforces expiry: a client that ignores it still gets
None from the resolver. Client-side expiry is a courtesy, server-side
expiry is the control.
Sourcepub fn clear(scope: impl Into<String>) -> Self
pub fn clear(scope: impl Into<String>) -> Self
Clear whatever token the client holds for scope.
Returning this also revokes the presented token server-side, through
SessionResolver::revoke. The destruction is the part that matters: a
client that ignores Clear-Session keeps a token, and that token has to
stop working regardless.
pub fn is_empty(&self) -> bool
Sourcepub fn token(&self) -> Option<&str>
pub fn token(&self) -> Option<&str>
The token this change issues, if it issues one.
Deliberately narrow: the token is already in the caller’s hand here — it put it there — so exposing it reveals nothing new. It exists so a caller can act on the session it just granted without threading the token separately through its own return values.