pub trait SessionResolver: Send + Sync {
// Required method
fn identity(&self, token: &str) -> Option<String>;
// Provided method
fn revoke(&self, token: &str) { ... }
}Expand description
Turns a session token into the identity it belongs to.
None means the token is unknown, expired or revoked. Those are one answer
on purpose: a caller that distinguished them would leak whether a token had
ever existed, and nothing downstream would do anything different.
Required Methods§
Provided Methods§
Sourcefn revoke(&self, token: &str)
fn revoke(&self, token: &str)
Destroy the session token names.
Called by the server, not by a handler, when a handler’s outcome clears the session — because a handler holds the identity and not the token, and so cannot name its own session to end it. Routing revocation through here keeps that boundary intact and still ends exactly the one session that was presented, rather than every session the person has.
A no-op by default, for a resolver whose sessions cannot be revoked.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".