pub struct TokenTimer {
pub expiry: DateTime<Utc>,
pub last_refreshed: DateTime<Utc>,
pub max_age: DateTime<Utc>,
}Expand description
Timer for managing IG API token expiration and refresh cycles
According to IG API documentation, tokens are initially valid for 6 hours but get extended up to a maximum of 72 hours while they are in use.
Fields§
§expiry: DateTime<Utc>The current expiry time of the token (initially 6 hours from creation)
last_refreshed: DateTime<Utc>The timestamp when the token was last refreshed
max_age: DateTime<Utc>The maximum age the token can reach (72 hours from initial creation)
Implementations§
Source§impl TokenTimer
impl TokenTimer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new TokenTimer with initial 6-hour expiry and 72-hour maximum age
§Returns
A new TokenTimer instance with expiry set to 6 hours from now and max_age set to 72 hours from now
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Checks if the token is expired based on current time
§Returns
true if either the token expiry time or maximum age has been reached, false otherwise
Sourcepub fn is_expired_w_margin(&self, margin: Duration) -> bool
pub fn is_expired_w_margin(&self, margin: Duration) -> bool
Trait Implementations§
Source§impl Clone for TokenTimer
impl Clone for TokenTimer
Source§fn clone(&self) -> TokenTimer
fn clone(&self) -> TokenTimer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TokenTimer
impl Debug for TokenTimer
Auto Trait Implementations§
impl Freeze for TokenTimer
impl RefUnwindSafe for TokenTimer
impl Send for TokenTimer
impl Sync for TokenTimer
impl Unpin for TokenTimer
impl UnwindSafe for TokenTimer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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