pub fn is_valid(&self) -> bool {
        let sys_time = SystemTime::now();
        let difference = sys_time.duration_since(self.created_at);
        match difference {
            Ok(duration) => {
                duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-9 < 600.0
            } // < 10 min
            Err(_) => false,
        }
    }
/// Verifies that the token is still valid to use it with the API.
/// Officially, a token is valid for 15 minutes but we keep this token valid for 10 minutes.
///
/// # Example
///
/// ```no_run
/// use rarbg_api::token::Token;
///
/// #[tokio::main]
/// async fn main() {
///     let token = Token::new("RustExample").await;
///     assert!(token.is_valid(), "Token should be valid !");
/// }
/// ```
Verifies that the token is still valid to use it with the API.
Officially, a token is valid for 15 minutes but we keep this token valid for 10 minutes.
Verifies that the token is still valid to use it with the API . Officially a token is valid for 15 minutes but we keep this token valid for 10 minutes .
pub fn is_valid(&self) -> bool {
        let sys_time = SystemTime::now();
        let difference = sys_time.duration_since(self.created_at);
        match difference {
            Ok(duration) => {
                duration.as_secs() as f64 + f64::from(duration.subsec_nanos()) * 1e-9 < 600.0
            } // < 10 min
            Err(_) => false,
        }
    }
pub fn is_valid ( & self ) -> bool { let sys_time = SystemTime :: now ( ) ; let difference = sys_time . duration_since ( self . created_at ) ; match difference { Ok ( duration ) => { duration . as_secs ( ) as f64 + f64 :: from ( duration . subsec_nanos ( ) ) * 1e-9 < 600.0 } // < 10 min Err ( _ ) => false , } }
Verifies that the token is still valid to use it with the API.
Verifies that the token is still valid to use it with the API .
&self
example
```no_run
use rarbg_api::token::Token.
` ` ` no_run use rarbg_api :: token :: Token .
[tokio::main]
async fn main() {
let token = Token::new("RustExample").await;
assert!(token.is_valid(), "Token should be valid !");
}
```
async fn main () { let token = Token :: new ( " RustExample " ) . await ; assert! ( token . is_valid () " Token should be valid ! " ) ; } ` ` `