Move namespace to dedicated dav crate

This commit is contained in:
Lennart
2023-09-14 13:30:58 +02:00
parent 1e6e97abfb
commit afae9bccc5
7 changed files with 11 additions and 3 deletions

View File

@@ -16,7 +16,6 @@ use tokio::sync::RwLock;
pub mod depth_extractor;
pub mod error;
pub mod namespace;
pub mod proptypes;
pub mod resource;
pub mod resources;

View File

@@ -1,44 +0,0 @@
use quick_xml::events::attributes::Attribute;
// An enum keeping track of the XML namespaces used for WebDAV and its extensions
//
// Can also generate appropriate attributes for quick_xml
pub enum Namespace {
Dav,
CalDAV,
CardDAV,
ICal,
CServer,
Nextcloud,
}
impl Namespace {
pub fn as_str(&self) -> &'static str {
match self {
Self::Dav => "DAV:",
Self::CalDAV => "urn:ietf:params:xml:ns:caldav",
Self::CardDAV => "urn:ietf:params:xml:ns:carddav",
Self::ICal => "http://apple.com/ns/ical/",
Self::CServer => "http://calendarserver.org/ns/",
Self::Nextcloud => "http://nextcloud.com/ns",
}
}
// Returns an opinionated namespace attribute name
pub fn xml_attr(&self) -> &'static str {
match self {
Self::Dav => "xmlns",
Self::CalDAV => "xmlns:C",
Self::CardDAV => "xmlns:CARD",
Self::ICal => "xmlns:IC",
Self::CServer => "xmlns:CS",
Self::Nextcloud => "xmlns:NEXTC",
}
}
}
impl From<Namespace> for Attribute<'static> {
fn from(value: Namespace) -> Self {
(value.xml_attr(), value.as_str()).into()
}
}

View File

@@ -1,4 +1,4 @@
use crate::namespace::Namespace;
use rustical_dav::namespace::Namespace;
use crate::resource::HandlePropfind;
use crate::resources::event::EventResource;
use crate::xml_snippets::generate_multistatus;

View File

@@ -1,5 +1,4 @@
use crate::depth_extractor::Depth;
use crate::namespace::Namespace;
use crate::resource::{HandlePropfind, Resource};
use crate::xml_snippets::generate_multistatus;
use crate::CalDavContext;
@@ -10,6 +9,7 @@ use actix_web::{HttpRequest, HttpResponse};
use anyhow::Result;
use quick_xml::events::BytesText;
use rustical_auth::{AuthInfoExtractor, CheckAuthentication};
use rustical_dav::namespace::Namespace;
use rustical_store::calendar::CalendarStore;
use thiserror::Error;