forked from Txio-labs/txio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.rs
More file actions
53 lines (48 loc) · 1.26 KB
/
Copy pathuser.rs
File metadata and controls
53 lines (48 loc) · 1.26 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use serde::{Deserialize, Serialize};
use mongodb::bson::oid::ObjectId;
use chrono::{DateTime, Utc};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct User {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>,
pub email: String,
pub password_hash: String,
pub tier: PlanTier,
#[serde(default)]
pub network: SuiNetwork,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Serialize, Deserialize, Clone, Default, clap::ValueEnum)]
pub enum SuiNetwork {
#[default]
Mainnet,
Testnet,
Devnet,
}
impl SuiNetwork {
pub fn url(&self) -> &'static str {
match self {
SuiNetwork::Mainnet => "https://fullnode.mainnet.sui.io:443",
SuiNetwork::Testnet => "https://fullnode.testnet.sui.io:443",
SuiNetwork::Devnet => "https://fullnode.devnet.sui.io:443",
}
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum PlanTier {
Free,
Pro,
Team,
}
impl User {
pub fn new(email: String, password_hash: String) -> Self {
Self {
id: None,
email,
password_hash,
tier: PlanTier::Free,
network: SuiNetwork::Mainnet,
created_at: Utc::now(),
}
}
}