pub struct WsBindingTokenManager { /* private fields */ }Expand description
Manages short-lived WebSocket binding tokens.
Clients call $get-ws-binding-token to obtain a token, then present it
as a query parameter when connecting to the WebSocket endpoint. Tokens
are consumed on first use and automatically expire.
Implementations§
Source§impl WsBindingTokenManager
impl WsBindingTokenManager
Sourcepub fn new(token_lifetime_secs: i64) -> Self
pub fn new(token_lifetime_secs: i64) -> Self
Creates a new token manager with the given token lifetime.
Sourcepub fn generate_token(
&self,
tenant_id: &str,
subscription_id: &str,
) -> (String, DateTime<Utc>)
pub fn generate_token( &self, tenant_id: &str, subscription_id: &str, ) -> (String, DateTime<Utc>)
Generates a short-lived binding token for a subscription.
Returns (token_string, expiration_datetime).
Sourcepub fn validate_and_consume(&self, token: &str) -> Option<(String, String)>
pub fn validate_and_consume(&self, token: &str) -> Option<(String, String)>
Validates and consumes a token (single-use).
Returns Some((tenant_id, subscription_id)) on success, None if
the token is invalid, expired, or already consumed.
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Removes all expired tokens.
Auto Trait Implementations§
impl !RefUnwindSafe for WsBindingTokenManager
impl Freeze for WsBindingTokenManager
impl Send for WsBindingTokenManager
impl Sync for WsBindingTokenManager
impl Unpin for WsBindingTokenManager
impl UnsafeUnpin for WsBindingTokenManager
impl UnwindSafe for WsBindingTokenManager
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
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>
Converts
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>
Converts
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 more