mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 14:02:29 +00:00
stores: Switch from dyn to impl and implement Sized
This commit is contained in:
@@ -11,7 +11,7 @@ use tracing::instrument;
|
||||
use tracing_actix_web::RootSpan;
|
||||
|
||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||
pub async fn get_object<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn get_object<AS: AddressbookStore>(
|
||||
path: Path<AddressObjectPathComponents>,
|
||||
store: Data<AS>,
|
||||
user: User,
|
||||
@@ -43,7 +43,7 @@ pub async fn get_object<AS: AddressbookStore + ?Sized>(
|
||||
}
|
||||
|
||||
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
|
||||
pub async fn put_object<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn put_object<AS: AddressbookStore>(
|
||||
path: Path<AddressObjectPathComponents>,
|
||||
store: Data<AS>,
|
||||
body: String,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{principal::PrincipalResource, Error};
|
||||
use actix_web::dev::ResourceMap;
|
||||
use async_trait::async_trait;
|
||||
use derive_more::derive::{From, Into};
|
||||
use derive_more::derive::{Constructor, From, Into};
|
||||
use rustical_dav::{
|
||||
privileges::UserPrivilegeSet,
|
||||
resource::{Resource, ResourceService},
|
||||
@@ -15,16 +15,11 @@ use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
|
||||
use super::methods::{get_object, put_object};
|
||||
|
||||
pub struct AddressObjectResourceService<AS: AddressbookStore + ?Sized> {
|
||||
#[derive(Constructor)]
|
||||
pub struct AddressObjectResourceService<AS: AddressbookStore> {
|
||||
addr_store: Arc<AS>,
|
||||
}
|
||||
|
||||
impl<A: AddressbookStore + ?Sized> AddressObjectResourceService<A> {
|
||||
pub fn new(addr_store: Arc<A>) -> Self {
|
||||
Self { addr_store }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, EnumDiscriminants, Clone)]
|
||||
#[strum_discriminants(
|
||||
name(AddressObjectPropName),
|
||||
@@ -111,7 +106,7 @@ impl<'de> Deserialize<'de> for AddressObjectPathComponents {
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl<AS: AddressbookStore + ?Sized> ResourceService for AddressObjectResourceService<AS> {
|
||||
impl<AS: AddressbookStore> ResourceService for AddressObjectResourceService<AS> {
|
||||
type PathComponents = AddressObjectPathComponents;
|
||||
type Resource = AddressObjectResource;
|
||||
type MemberType = AddressObjectResource;
|
||||
|
||||
@@ -32,7 +32,7 @@ struct MkcolRequest {
|
||||
}
|
||||
|
||||
#[instrument(parent = root_span.id(), skip(store, root_span))]
|
||||
pub async fn route_mkcol<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn route_mkcol<AS: AddressbookStore>(
|
||||
path: Path<(String, String)>,
|
||||
body: String,
|
||||
user: User,
|
||||
|
||||
@@ -10,7 +10,7 @@ use tracing::instrument;
|
||||
use tracing_actix_web::RootSpan;
|
||||
|
||||
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
|
||||
pub async fn route_post<A: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized>(
|
||||
pub async fn route_post<A: AddressbookStore, S: SubscriptionStore>(
|
||||
path: Path<(String, String)>,
|
||||
body: String,
|
||||
user: User,
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct AddressbookMultigetRequest {
|
||||
href: Vec<String>,
|
||||
}
|
||||
|
||||
pub async fn get_objects_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn get_objects_addressbook_multiget<AS: AddressbookStore>(
|
||||
addressbook_multiget: &AddressbookMultigetRequest,
|
||||
path: &str,
|
||||
principal: &str,
|
||||
@@ -52,7 +52,7 @@ pub async fn get_objects_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
||||
Ok((result, not_found))
|
||||
}
|
||||
|
||||
pub async fn handle_addressbook_multiget<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn handle_addressbook_multiget<AS: AddressbookStore>(
|
||||
addr_multiget: AddressbookMultigetRequest,
|
||||
req: HttpRequest,
|
||||
user: &User,
|
||||
|
||||
@@ -19,7 +19,7 @@ pub(crate) enum ReportRequest {
|
||||
}
|
||||
|
||||
#[instrument(skip(req, addr_store))]
|
||||
pub async fn route_report_addressbook<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn route_report_addressbook<AS: AddressbookStore>(
|
||||
path: Path<(String, String)>,
|
||||
body: String,
|
||||
user: User,
|
||||
|
||||
@@ -56,7 +56,7 @@ pub(crate) struct SyncCollectionRequest {
|
||||
pub(crate) limit: Option<u64>,
|
||||
}
|
||||
|
||||
pub async fn handle_sync_collection<AS: AddressbookStore + ?Sized>(
|
||||
pub async fn handle_sync_collection<AS: AddressbookStore>(
|
||||
sync_collection: SyncCollectionRequest,
|
||||
req: HttpRequest,
|
||||
user: &User,
|
||||
|
||||
@@ -22,13 +22,13 @@ use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
|
||||
pub struct AddressbookResourceService<AS: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized>
|
||||
pub struct AddressbookResourceService<AS: AddressbookStore, S: SubscriptionStore>
|
||||
{
|
||||
addr_store: Arc<AS>,
|
||||
__phantom_sub: PhantomData<S>,
|
||||
}
|
||||
|
||||
impl<A: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized> AddressbookResourceService<A, S> {
|
||||
impl<A: AddressbookStore, S: SubscriptionStore> AddressbookResourceService<A, S> {
|
||||
pub fn new(addr_store: Arc<A>) -> Self {
|
||||
Self {
|
||||
addr_store,
|
||||
@@ -174,7 +174,7 @@ impl Resource for AddressbookResource {
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl<AS: AddressbookStore + ?Sized, S: SubscriptionStore + ?Sized> ResourceService
|
||||
impl<AS: AddressbookStore, S: SubscriptionStore> ResourceService
|
||||
for AddressbookResourceService<AS, S>
|
||||
{
|
||||
type MemberType = AddressObjectResource;
|
||||
|
||||
@@ -29,11 +29,7 @@ pub fn configure_well_known(cfg: &mut web::ServiceConfig, carddav_root: String)
|
||||
cfg.service(web::redirect("/carddav", carddav_root).permanent());
|
||||
}
|
||||
|
||||
pub fn configure_dav<
|
||||
AP: AuthenticationProvider,
|
||||
A: AddressbookStore + ?Sized,
|
||||
S: SubscriptionStore + ?Sized,
|
||||
>(
|
||||
pub fn configure_dav<AP: AuthenticationProvider, A: AddressbookStore, S: SubscriptionStore>(
|
||||
cfg: &mut web::ServiceConfig,
|
||||
auth_provider: Arc<AP>,
|
||||
store: Arc<A>,
|
||||
|
||||
@@ -11,11 +11,11 @@ use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
use std::sync::Arc;
|
||||
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
|
||||
|
||||
pub struct PrincipalResourceService<A: AddressbookStore + ?Sized> {
|
||||
pub struct PrincipalResourceService<A: AddressbookStore> {
|
||||
addr_store: Arc<A>,
|
||||
}
|
||||
|
||||
impl<A: AddressbookStore + ?Sized> PrincipalResourceService<A> {
|
||||
impl<A: AddressbookStore> PrincipalResourceService<A> {
|
||||
pub fn new(addr_store: Arc<A>) -> Self {
|
||||
Self { addr_store }
|
||||
}
|
||||
@@ -102,7 +102,7 @@ impl Resource for PrincipalResource {
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl<A: AddressbookStore + ?Sized> ResourceService for PrincipalResourceService<A> {
|
||||
impl<A: AddressbookStore> ResourceService for PrincipalResourceService<A> {
|
||||
type PathComponents = (String,);
|
||||
type MemberType = AddressbookResource;
|
||||
type Resource = PrincipalResource;
|
||||
|
||||
Reference in New Issue
Block a user