/** * welcum to the cache zone * Notes about data model here * Basically none of the ever gets written to disk so its mutability is * * Memory Model things * The cache should always own its own data and nothing else * On calls where the cache system needs to take data it should actually * make its own copy to not disturb the render side of things as it too requires * ownership of its own data. For this reason all parts of this are basically * going to be really selfish about its own data * */ use crate::config::{ ServerMeta, UserConfig }; use crate::api_types::{Channel, Message}; use crate::command::Command; use std::collections::HashMap; struct ChannelCache { meta: Channel, messages: Vec } struct ServerCache { meta: ServerMeta, user: UserConfig, channels: Vec } pub struct Cache { // Hostname -> Cache servers: HashMap, active_server: Option } impl Default for Cache { fn default() -> Cache { Cache { servers: HashMap::new(), active_server: None } } } impl Cache { pub async fn switch_channel(&mut self, id: u64) -> Command { todo!() } pub async fn switch_server(&mut self, host: &str) -> Command { todo!() } pub async fn send_message(&mut self, id: &str) -> Command { todo!() } }