gemini / server /src /models /account.rs
yinming
feat: Antigravity API Proxy for HuggingFace Spaces
bbb1195
use serde::{Deserialize, Serialize};
use super::{token::TokenData, quota::QuotaData};
/// Account data structure
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Account {
pub id: String,
pub email: String,
pub name: Option<String>,
pub token: TokenData,
pub quota: Option<QuotaData>,
pub created_at: i64,
pub last_used: i64,
}
impl Account {
pub fn new(id: String, email: String, token: TokenData) -> Self {
let now = chrono::Utc::now().timestamp();
Self {
id,
email,
name: None,
token,
quota: None,
created_at: now,
last_used: now,
}
}
pub fn update_last_used(&mut self) {
self.last_used = chrono::Utc::now().timestamp();
}
pub fn update_quota(&mut self, quota: QuotaData) {
self.quota = Some(quota);
}
}
/// Account index (accounts.json)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountIndex {
pub version: String,
pub accounts: Vec<AccountSummary>,
pub current_account_id: Option<String>,
}
/// Account summary
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccountSummary {
pub id: String,
pub email: String,
pub name: Option<String>,
pub created_at: i64,
pub last_used: i64,
}
impl AccountIndex {
pub fn new() -> Self {
Self {
version: "2.0".to_string(),
accounts: Vec::new(),
current_account_id: None,
}
}
}
impl Default for AccountIndex {
fn default() -> Self {
Self::new()
}
}