Refactor store crate

This commit is contained in:
Lennart
2024-09-30 18:23:30 +02:00
parent 2670abfef0
commit acc47e4e24
14 changed files with 18 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ use crate::Error;
use actix_web::web::{Data, Path}; use actix_web::web::{Data, Path};
use actix_web::HttpResponse; use actix_web::HttpResponse;
use rustical_auth::{AuthInfoExtractor, CheckAuthentication}; use rustical_auth::{AuthInfoExtractor, CheckAuthentication};
use rustical_store::calendar::Calendar; use rustical_store::model::Calendar;
use rustical_store::CalendarStore; use rustical_store::CalendarStore;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@@ -11,7 +11,7 @@ use rustical_dav::{
resource::HandlePropfind, resource::HandlePropfind,
xml::{multistatus::PropstatWrapper, MultistatusElement}, xml::{multistatus::PropstatWrapper, MultistatusElement},
}; };
use rustical_store::{event::Event, CalendarStore}; use rustical_store::{model::Event, CalendarStore};
use serde::Deserialize; use serde::Deserialize;
use tokio::sync::RwLock; use tokio::sync::RwLock;

View File

@@ -4,7 +4,7 @@ use rustical_dav::{
resource::HandlePropfind, resource::HandlePropfind,
xml::{multistatus::PropstatWrapper, MultistatusElement}, xml::{multistatus::PropstatWrapper, MultistatusElement},
}; };
use rustical_store::{event::Event, CalendarStore}; use rustical_store::{model::Event, CalendarStore};
use serde::Deserialize; use serde::Deserialize;
use tokio::sync::RwLock; use tokio::sync::RwLock;

View File

@@ -8,7 +8,7 @@ use rustical_dav::{
}, },
}; };
use rustical_store::{ use rustical_store::{
calendar::{format_synctoken, parse_synctoken}, model::calendar::{format_synctoken, parse_synctoken},
CalendarStore, CalendarStore,
}; };
use serde::Deserialize; use serde::Deserialize;

View File

@@ -5,7 +5,7 @@ use async_trait::async_trait;
use derive_more::derive::{From, Into}; use derive_more::derive::{From, Into};
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService}; use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
use rustical_dav::xml::HrefElement; use rustical_dav::xml::HrefElement;
use rustical_store::calendar::Calendar; use rustical_store::model::Calendar;
use rustical_store::CalendarStore; use rustical_store::CalendarStore;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::Arc; use std::sync::Arc;

View File

@@ -3,7 +3,7 @@ use actix_web::{web::Data, HttpRequest};
use async_trait::async_trait; use async_trait::async_trait;
use derive_more::derive::{From, Into}; use derive_more::derive::{From, Into};
use rustical_dav::resource::{InvalidProperty, Resource, ResourceService}; use rustical_dav::resource::{InvalidProperty, Resource, ResourceService};
use rustical_store::event::Event; use rustical_store::model::Event;
use rustical_store::CalendarStore; use rustical_store::CalendarStore;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::sync::Arc; use std::sync::Arc;

View File

@@ -1,8 +1,7 @@
pub mod calendar;
pub mod error; pub mod error;
pub mod event; pub mod model;
pub mod sqlite_store; pub mod sqlite_store;
pub mod store; pub mod store;
pub mod timestamps; pub mod timestamp;
pub use error::Error; pub use error::Error;
pub use store::CalendarStore; pub use store::CalendarStore;

View File

@@ -1,5 +1,5 @@
use crate::{ use crate::{
timestamps::{parse_duration, CalDateTime}, timestamp::{parse_duration, CalDateTime},
Error, Error,
}; };
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};

View File

@@ -0,0 +1,5 @@
pub mod calendar;
pub mod event;
pub use calendar::Calendar;
pub use event::Event;

View File

@@ -1,5 +1,5 @@
use crate::calendar::Calendar; use crate::model::Calendar;
use crate::event::Event; use crate::model::Event;
use crate::{CalendarStore, Error}; use crate::{CalendarStore, Error};
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;

View File

@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use crate::error::Error; use crate::error::Error;
use crate::{calendar::Calendar, event::Event}; use crate::model::{Calendar, Event};
#[async_trait] #[async_trait]
pub trait CalendarStore: Send + Sync + 'static { pub trait CalendarStore: Send + Sync + 'static {

View File

@@ -26,7 +26,7 @@ async fn test_init<CS: CalendarStore>(_store: CS) {
#[tokio::test] #[tokio::test]
async fn test_create_event<CS: CalendarStore>(mut store: CS) { async fn test_create_event<CS: CalendarStore>(mut store: CS) {
store store
.insert_calendar(rustical_store::calendar::Calendar { .insert_calendar(rustical_store::model::Calendar {
id: "test".to_owned(), id: "test".to_owned(),
displayname: Some("Test Calendar".to_owned()), displayname: Some("Test Calendar".to_owned()),
principal: "testuser".to_owned(), principal: "testuser".to_owned(),