pub struct TokenRegistry {
map: RwLock<HashMap<String, TokenRecord>>,
}Expand description
Thread-safe, in-memory store of live token records.
Wrapped in Arc so it can be cloned cheaply into the axum app state and
the Tauri-managed super::MediaServerHandle.
Fields§
§map: RwLock<HashMap<String, TokenRecord>>Implementations§
Source§impl TokenRegistry
impl TokenRegistry
Sourcepub fn mint(
&self,
profile_id: ProfileId,
bucket: BucketId,
key: String,
region: String,
ttl_secs: u64,
session_id: String,
) -> (String, i64)
pub fn mint( &self, profile_id: ProfileId, bucket: BucketId, key: String, region: String, ttl_secs: u64, session_id: String, ) -> (String, i64)
Mint a fresh token for the given S3 object.
Returns (token, expires_at) where token is the URL-safe base64
string (64 chars, 48 random bytes) and expires_at is a Unix epoch
seconds timestamp.
§Arguments
profile_id— profile whose credentials service the request.bucket/key— S3 coordinates.region— AWS region for the bucket (used to route get_object).ttl_secs— seconds until expiry (1-hour default → pass3600).session_id— calling session; used byrevoke_session.
Sourcepub fn lookup(&self, token: &str) -> Option<TokenRecord>
pub fn lookup(&self, token: &str) -> Option<TokenRecord>
Look up a token. Returns None when unknown or expired.
Sourcepub fn lookup_with_status(&self, token: &str) -> Result<Option<TokenRecord>, ()>
pub fn lookup_with_status(&self, token: &str) -> Result<Option<TokenRecord>, ()>
Variant of lookup that distinguishes “token unknown” from “token expired”.
Ok(Some(record))— token is known and live.Ok(None)— token is known but expired → 403.Err(())— token does not exist → 404.
Sourcepub fn revoke_session(&self, session_id: &str)
pub fn revoke_session(&self, session_id: &str)
Remove all tokens belonging to session_id.
Called on session end so no token outlives its session.
Trait Implementations§
Source§impl Default for TokenRegistry
impl Default for TokenRegistry
Source§fn default() -> TokenRegistry
fn default() -> TokenRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for TokenRegistry
impl RefUnwindSafe for TokenRegistry
impl Send for TokenRegistry
impl Sync for TokenRegistry
impl Unpin for TokenRegistry
impl UnsafeUnpin for TokenRegistry
impl UnwindSafe for TokenRegistry
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.