mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 14:02:29 +00:00
move CalendarStore to separate file
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
use crate::event::Event;
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize, Serialize)]
|
||||
@@ -12,16 +9,3 @@ pub struct Calendar {
|
||||
pub color: Option<String>,
|
||||
pub timezone: Option<String>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait CalendarStore: Send + Sync + 'static {
|
||||
async fn get_calendar(&self, id: &str) -> Result<Calendar>;
|
||||
async fn get_calendars(&self, owner: &str) -> Result<Vec<Calendar>>;
|
||||
async fn insert_calendar(&mut self, cid: String, calendar: Calendar) -> Result<()>;
|
||||
async fn delete_calendar(&mut self, cid: &str) -> Result<()>;
|
||||
|
||||
async fn get_events(&self, cid: &str) -> Result<Vec<Event>>;
|
||||
async fn get_event(&self, cid: &str, uid: &str) -> Result<Event>;
|
||||
async fn upsert_event(&mut self, cid: String, uid: String, ics: String) -> Result<()>;
|
||||
async fn delete_event(&mut self, cid: &str, uid: &str) -> Result<()>;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
pub mod calendar;
|
||||
pub mod event;
|
||||
pub mod sqlite_store;
|
||||
pub mod store;
|
||||
pub mod timestamps;
|
||||
pub mod toml_store;
|
||||
|
||||
@@ -2,10 +2,7 @@ use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use sqlx::{sqlite::SqliteConnectOptions, Pool, Sqlite, SqlitePool};
|
||||
|
||||
use crate::{
|
||||
calendar::{Calendar, CalendarStore},
|
||||
event::Event,
|
||||
};
|
||||
use crate::{calendar::Calendar, event::Event, store::CalendarStore};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SqliteCalendarStore {
|
||||
|
||||
17
crates/store/src/store.rs
Normal file
17
crates/store/src/store.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::{calendar::Calendar, event::Event};
|
||||
|
||||
#[async_trait]
|
||||
pub trait CalendarStore: Send + Sync + 'static {
|
||||
async fn get_calendar(&self, id: &str) -> Result<Calendar>;
|
||||
async fn get_calendars(&self, owner: &str) -> Result<Vec<Calendar>>;
|
||||
async fn insert_calendar(&mut self, cid: String, calendar: Calendar) -> Result<()>;
|
||||
async fn delete_calendar(&mut self, cid: &str) -> Result<()>;
|
||||
|
||||
async fn get_events(&self, cid: &str) -> Result<Vec<Event>>;
|
||||
async fn get_event(&self, cid: &str, uid: &str) -> Result<Event>;
|
||||
async fn upsert_event(&mut self, cid: String, uid: String, ics: String) -> Result<()>;
|
||||
async fn delete_event(&mut self, cid: &str, uid: &str) -> Result<()>;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::calendar::{Calendar, CalendarStore};
|
||||
use crate::calendar::Calendar;
|
||||
use crate::event::Event;
|
||||
use crate::store::CalendarStore;
|
||||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
Reference in New Issue
Block a user