71 lines
1.3 KiB
Rust
71 lines
1.3 KiB
Rust
use rust_decimal::Decimal;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)]
|
|
pub struct ApiKey(Uuid);
|
|
|
|
impl ApiKey {
|
|
pub fn inner(&self) -> &Uuid {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize, Serialize)]
|
|
#[serde(transparent)]
|
|
pub struct Username(String);
|
|
|
|
impl Username {
|
|
pub fn inner(&self) -> &str {
|
|
&self.0
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default, Deserialize)]
|
|
#[serde(transparent)]
|
|
pub struct Password(String);
|
|
|
|
impl Password {
|
|
pub fn as_bytes(&self) -> &[u8] {
|
|
self.0.as_bytes()
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(transparent)]
|
|
pub struct UserBalance(Decimal);
|
|
|
|
impl UserBalance {
|
|
pub fn new(decimal: Decimal) -> Self {
|
|
Self(decimal)
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(transparent)]
|
|
pub struct UserDebt(Decimal);
|
|
|
|
impl UserDebt {
|
|
pub fn new(decimal: Decimal) -> Self {
|
|
Self(decimal)
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
pub struct User {
|
|
username: Username,
|
|
balance: UserBalance,
|
|
debt: UserDebt,
|
|
}
|
|
|
|
impl User {
|
|
pub fn new(username: Username, balance: UserBalance, debt: UserDebt) -> Self {
|
|
Self {
|
|
username,
|
|
balance,
|
|
debt,
|
|
}
|
|
}
|
|
}
|