Derive speedy serialization traits where we can (and serde where we missed) for stored data

This commit is contained in:
Mike Dilger 2023-07-09 00:35:22 +12:00
parent 675d19b5f3
commit 955d25d61a
5 changed files with 11 additions and 6 deletions

View File

@ -2,9 +2,10 @@ use crate::error::Error;
use crate::globals::GLOBALS;
use nostr_types::Id;
use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};
use tokio::task::spawn_blocking;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Readable, Writable)]
pub struct DbEventFlags {
pub event: Id,
pub viewed: bool,

View File

@ -3,9 +3,10 @@ use crate::error::Error;
use crate::globals::GLOBALS;
use gossip_relay_picker::Direction;
use nostr_types::{PublicKeyHex, RelayUrl, Unixtime};
use speedy::{Readable, Writable};
use tokio::task::spawn_blocking;
#[derive(Debug)]
#[derive(Debug, Readable, Writable)]
pub struct DbPersonRelay {
// The person
pub person: String,

View File

@ -1,9 +1,10 @@
use crate::error::Error;
use crate::globals::GLOBALS;
use nostr_types::{Id, RelayInformationDocument, RelayUrl};
use serde::{Deserialize, Serialize};
use tokio::task::spawn_blocking;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DbRelay {
pub url: RelayUrl,
pub success_count: u64,

View File

@ -4,8 +4,9 @@ use crate::ui::{Theme, ThemeVariant};
use nostr_types::{EventKind, PublicKey};
use rusqlite::params;
use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[derive(Clone, Debug, Serialize, Deserialize, Readable, Writable)]
pub struct Settings {
pub feed_chunk: u64,
pub replies_chunk: u64,

View File

@ -6,6 +6,7 @@ use eframe::egui::{
};
use eframe::epaint::{FontFamily, FontId, Shadow};
use serde::{Deserialize, Serialize};
use speedy::{Readable, Writable};
use std::collections::BTreeMap;
mod classic;
@ -26,14 +27,14 @@ pub fn apply_theme(theme: Theme, ctx: &Context) {
}
// note: if we store anything inside the variants, we can't use macro_rules.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Readable, Writable)]
pub enum ThemeVariant {
Classic,
Default,
Roundy,
}
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, Serialize, Deserialize, Readable, Writable)]
pub struct Theme {
pub variant: ThemeVariant,
pub dark_mode: bool,