#![allow(unused)] #![allow(clippy::all)] use crate::db::schema::{self, aead_encrypted, arbiter_settings, root_key_history, tls_history}; use diesel::{prelude::*, sqlite::Sqlite}; use restructed::Models; pub mod types { use chrono::{DateTime, Utc}; pub struct SqliteTimestamp(DateTime); } #[derive(Models, Queryable, Debug, Insertable, Selectable)] #[view( NewAeadEncrypted, derive(Insertable), omit(id), attributes_with = "deriveless" )] #[diesel(table_name = aead_encrypted, check_for_backend(Sqlite))] pub struct AeadEncrypted { pub id: i32, pub ciphertext: Vec, pub tag: Vec, pub current_nonce: Vec, pub schema_version: i32, pub associated_root_key_id: i32, // references root_key_history.id pub created_at: i32, } #[derive(Models, Queryable, Debug, Insertable, Selectable)] #[diesel(table_name = root_key_history, check_for_backend(Sqlite))] #[view( NewRootKeyHistory, derive(Insertable), omit(id), attributes_with = "deriveless" )] pub struct RootKeyHistory { pub id: i32, pub ciphertext: Vec, pub tag: Vec, pub root_key_encryption_nonce: Vec, pub data_encryption_nonce: Vec, pub schema_version: i32, pub salt: Vec, } #[derive(Models, Queryable, Debug, Insertable, Selectable)] #[diesel(table_name = tls_history, check_for_backend(Sqlite))] #[view( NewTlsHistory, derive(Insertable), omit(id, created_at), attributes_with = "deriveless" )] pub struct TlsHistory { pub id: i32, pub cert: String, pub cert_key: String, // PEM Encoded private key pub ca_cert: String, // PEM Encoded certificate for cert signing pub ca_key: String, // PEM Encoded public key for cert signing pub created_at: i32, } #[derive(Queryable, Debug, Insertable, Selectable)] #[diesel(table_name = arbiter_settings, check_for_backend(Sqlite))] pub struct ArbiterSettings { pub id: i32, pub root_key_id: Option, // references root_key_history.id pub tls_id: Option, // references tls_history.id } #[derive(Queryable, Debug)] #[diesel(table_name = schema::program_client, check_for_backend(Sqlite))] pub struct ProgramClient { pub id: i32, pub public_key: Vec, pub nonce: i32, pub created_at: i32, pub updated_at: i32, } #[derive(Queryable, Debug)] #[diesel(table_name = schema::useragent_client, check_for_backend(Sqlite))] pub struct UseragentClient { pub id: i32, pub public_key: Vec, pub nonce: i32, pub created_at: i32, pub updated_at: i32, }