diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-20 17:31:54 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-03-20 17:31:54 +0100 |
commit | ed47855ef1a6c9d10d48080367ff8b280530e362 (patch) | |
tree | fc79b171718598c84034e212a6b8746a5fb6b782 /aero-collections/src/calendar | |
parent | 22e4f295556fdd4c25cf43983a56ff74acab7739 (diff) | |
download | aerogramme-ed47855ef1a6c9d10d48080367ff8b280530e362.tar.gz aerogramme-ed47855ef1a6c9d10d48080367ff8b280530e362.zip |
Share UniqueIdent between collections
Diffstat (limited to 'aero-collections/src/calendar')
-rw-r--r-- | aero-collections/src/calendar/mod.rs | 6 | ||||
-rw-r--r-- | aero-collections/src/calendar/namespace.rs | 47 |
2 files changed, 52 insertions, 1 deletions
diff --git a/aero-collections/src/calendar/mod.rs b/aero-collections/src/calendar/mod.rs index 19e3340..708e1f1 100644 --- a/aero-collections/src/calendar/mod.rs +++ b/aero-collections/src/calendar/mod.rs @@ -1 +1,5 @@ -//@FIXME Event Index +pub mod namespace; + +pub struct Calendar { + a: u64, +} diff --git a/aero-collections/src/calendar/namespace.rs b/aero-collections/src/calendar/namespace.rs new file mode 100644 index 0000000..cf8a159 --- /dev/null +++ b/aero-collections/src/calendar/namespace.rs @@ -0,0 +1,47 @@ +use anyhow::Result; +use std::collections::{HashMap, BTreeMap}; +use std::sync::{Weak, Arc}; + +use serde::{Deserialize, Serialize}; + +use aero_user::storage; + +use crate::unique_ident::UniqueIdent; +use crate::user::User; +use super::Calendar; + +pub(crate) const CAL_LIST_PK: &str = "calendars"; +pub(crate) const CAL_LIST_SK: &str = "list"; + +pub(crate) struct CalendarNs(std::sync::Mutex<HashMap<UniqueIdent, Weak<Calendar>>>); +impl CalendarNs { + pub fn new() -> Self { + Self(std::sync::Mutex::new(HashMap::new())) + } + + pub fn list(&self) { + todo!(); + } +} + +#[derive(Serialize, Deserialize)] +pub(crate) struct CalendarList(BTreeMap<String, CalendarListEntry>); + +#[derive(Serialize, Deserialize, Clone, Copy, Debug)] +pub(crate) struct CalendarListEntry { + id_lww: (u64, Option<UniqueIdent>), +} + +impl CalendarList { + pub(crate) async fn load(user: &Arc<User>) -> Result<(Self, Option<storage::RowRef>)> { + todo!(); + } + + pub(crate) async fn save(user: &Arc<User>, ct: Option<storage::RowRef>) -> Result<()> { + todo!(); + } + + pub(crate) fn new() -> Self { + Self(BTreeMap::new()) + } +} |