blob: 39c4ce03a75bb3e8dbeca47203e35833b7286717 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OfflineAccount {
pub username: String,
pub uuid: String,
}
pub struct AccountState {
pub active_account: Mutex<Option<OfflineAccount>>,
}
impl AccountState {
pub fn new() -> Self {
Self {
active_account: Mutex::new(None),
}
}
}
pub fn generate_offline_uuid(username: &str) -> String {
// Generate a UUID v3 (MD5-based) using the username as the name
// This provides a consistent UUID for the same username
let namespace = Uuid::NAMESPACE_OID;
Uuid::new_v3(&namespace, username.as_bytes()).to_string()
}
|