pub struct TokenInfo {
pub token: String,
pub service_id: ServiceId,
pub request_id: String,
pub created_at: Instant,
pub expires_at: Instant,
pub allowed_types: Vec<String>,
pub usage_count: u32,
pub max_uses: u32,
}Expand description
Token information
Fields§
§token: StringThe token value
service_id: ServiceIdService ID that owns this token
request_id: StringRequest ID this token is associated with
created_at: InstantWhen the token was created
expires_at: InstantWhen the token expires
allowed_types: Vec<String>Allowed callback types
usage_count: u32Usage count
max_uses: u32Maximum allowed uses
Implementations§
Source§impl TokenInfo
impl TokenInfo
Sourcepub fn new(
token: String,
service_id: ServiceId,
request_id: String,
lifetime_secs: u64,
) -> Self
pub fn new( token: String, service_id: ServiceId, request_id: String, lifetime_secs: u64, ) -> Self
Create a new token info
Sourcepub fn with_allowed_types(self, types: Vec<String>) -> Self
pub fn with_allowed_types(self, types: Vec<String>) -> Self
Set allowed callback types
Sourcepub fn with_max_uses(self, max: u32) -> Self
pub fn with_max_uses(self, max: u32) -> Self
Set maximum uses
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if token is expired
Sourcepub fn has_remaining_uses(&self) -> bool
pub fn has_remaining_uses(&self) -> bool
Check if token has remaining uses
Sourcepub fn is_type_allowed(&self, callback_type: &str) -> bool
pub fn is_type_allowed(&self, callback_type: &str) -> bool
Check if callback type is allowed
Sourcepub fn increment_usage(&mut self)
pub fn increment_usage(&mut self)
Increment usage count
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokenInfo
impl RefUnwindSafe for TokenInfo
impl Send for TokenInfo
impl Sync for TokenInfo
impl Unpin for TokenInfo
impl UnsafeUnpin for TokenInfo
impl UnwindSafe for TokenInfo
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