rust-nex/rnex-core/src/nex/account.rs

32 lines
722 B
Rust
Raw Normal View History

2025-06-29 11:40:42 +02:00
use macros::RmcSerialize;
2025-02-01 17:18:52 +01:00
2026-03-24 15:48:56 +01:00
use rnex_core::PID;
2026-01-31 13:48:06 +01:00
#[derive(RmcSerialize, Clone)]
pub struct Account {
2026-03-24 15:48:56 +01:00
pub pid: PID,
2025-06-29 11:40:42 +02:00
pub username: String,
2026-02-01 21:31:32 +01:00
pub kerbros_password: Box<[u8]>,
2025-02-01 17:18:52 +01:00
}
2026-01-31 13:48:06 +01:00
impl Account {
2026-03-24 15:48:56 +01:00
pub fn new(pid: PID, username: &str, passwd: &str) -> Self {
2026-01-31 13:48:06 +01:00
Self {
2026-02-01 21:31:32 +01:00
kerbros_password: passwd.as_bytes().into(),
username: username.into(),
2026-01-31 13:48:06 +01:00
pid,
}
}
2026-03-24 15:48:56 +01:00
pub fn new_raw_password(pid: PID, username: &str, passwd: &[u8]) -> Self {
2026-01-31 13:48:06 +01:00
Self {
2026-02-01 21:31:32 +01:00
kerbros_password: passwd.into(),
username: username.into(),
2026-01-31 13:48:06 +01:00
pid,
2025-02-01 17:18:52 +01:00
}
}
2026-03-24 15:48:56 +01:00
pub fn get_login_data(&self) -> (PID, &[u8]) {
2026-01-31 13:48:06 +01:00
(self.pid, &self.kerbros_password)
}
2026-01-31 13:48:06 +01:00
}