Download server/src/models/account.rs from AZILS/gemini: direct link, hf CLI and curl.
- Browser
- Download file 1.62 kB
-
https://huggingface.co/spaces/AZILS/gemini/resolve/main/server/src/models/account.rs
- Command line
-
hf download hf://spaces/AZILS/gemini/server/src/models/account.rs
-
curl -L -o account.rs https://huggingface.co/spaces/AZILS/gemini/resolve/main/server/src/models/account.rs
1.62 kB
| use serde::{Deserialize, Serialize}; | |
| use super::{token::TokenData, quota::QuotaData}; | |
| /// Account data structure | |
| 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) | |
| pub struct AccountIndex { | |
| pub version: String, | |
| pub accounts: Vec<AccountSummary>, | |
| pub current_account_id: Option<String>, | |
| } | |
| /// Account summary | |
| 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() | |
| } | |
| } | |