Skip to main content

lockbook_server_lib/
schema.rs

1use db_rs::{LookupMap, LookupSet, LookupTable, Single};
2use db_rs_derive::Schema;
3use lb_rs::model::file_metadata::{DocumentHmac, Owner};
4use lb_rs::model::server_meta::ServerMeta;
5use lb_rs::service::debug::DebugInfo;
6use lb_rs::service::lb_id::LbID;
7use serde::{Deserialize, Serialize};
8use uuid::Uuid;
9
10use crate::{billing::billing_model::SubscriptionProfile, defense::BandwidthReport};
11
12#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
13pub struct OneKey;
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct Account {
17    pub username: String,
18    pub billing_info: SubscriptionProfile,
19}
20
21pub type ServerDb = ServerV5;
22
23#[derive(Schema)]
24#[cfg_attr(feature = "no-network", derive(Clone))]
25pub struct ServerV5 {
26    pub usernames: LookupTable<String, Owner>,
27    pub metas: LookupTable<Uuid, ServerMeta>,
28    pub google_play_ids: LookupTable<String, Owner>,
29    pub stripe_ids: LookupTable<String, Owner>,
30    pub app_store_ids: LookupTable<String, Owner>,
31    pub last_seen: LookupTable<Owner, u64>,
32    pub accounts: LookupTable<Owner, Account>,
33    pub owned_files: LookupSet<Owner, Uuid>,
34    pub shared_files: LookupSet<Owner, Uuid>,
35    pub file_children: LookupSet<Uuid, Uuid>,
36    pub server_egress: Single<BandwidthReport>,
37    pub egress_by_owner: LookupTable<Owner, BandwidthReport>,
38    pub scheduled_file_cleanups: LookupTable<(Uuid, DocumentHmac), i64>,
39    pub debug_info: LookupMap<Owner, LbID, DebugInfo>,
40}