sylvia_iot_auth/models/
access_token.rsuse std::error::Error as StdError;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
#[derive(Debug, PartialEq)]
pub struct AccessToken {
pub access_token: String,
pub refresh_token: Option<String>,
pub expires_at: DateTime<Utc>,
pub scope: Option<String>,
pub client_id: String,
pub redirect_uri: String,
pub user_id: String,
}
#[derive(Default)]
pub struct QueryCond<'a> {
pub access_token: Option<&'a str>,
pub refresh_token: Option<&'a str>,
pub client_id: Option<&'a str>,
pub user_id: Option<&'a str>,
}
#[async_trait]
pub trait AccessTokenModel: Sync {
async fn init(&self) -> Result<(), Box<dyn StdError>>;
async fn get(&self, access_token: &str) -> Result<Option<AccessToken>, Box<dyn StdError>>;
async fn add(&self, token: &AccessToken) -> Result<(), Box<dyn StdError>>;
async fn del(&self, cond: &QueryCond) -> Result<(), Box<dyn StdError>>;
}
pub const EXPIRES: i64 = 1 * 60 * 60;