mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
run clippy fix
This commit is contained in:
@@ -35,7 +35,7 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn status_code(&self) -> StatusCode {
|
||||
#[must_use] pub const fn status_code(&self) -> StatusCode {
|
||||
match self {
|
||||
Self::InternalError => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::NotFound => StatusCode::NOT_FOUND,
|
||||
@@ -50,8 +50,8 @@ impl Error {
|
||||
| XmlError::InvalidValue(_) => StatusCode::UNPROCESSABLE_ENTITY,
|
||||
_ => StatusCode::BAD_REQUEST,
|
||||
},
|
||||
Error::PropReadOnly => StatusCode::CONFLICT,
|
||||
Error::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
|
||||
Self::PropReadOnly => StatusCode::CONFLICT,
|
||||
Self::PreconditionFailed => StatusCode::PRECONDITION_FAILED,
|
||||
Self::IOError(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Self::Forbidden => StatusCode::FORBIDDEN,
|
||||
}
|
||||
@@ -68,7 +68,7 @@ impl axum::response::IntoResponse for Error {
|
||||
}
|
||||
|
||||
let mut resp = axum::response::Response::builder().status(self.status_code());
|
||||
if matches!(&self, &Error::Unauthorized) {
|
||||
if matches!(&self, &Self::Unauthorized) {
|
||||
resp.headers_mut()
|
||||
.expect("This must always work")
|
||||
.insert("WWW-Authenticate", "Basic".parse().unwrap());
|
||||
|
||||
@@ -40,7 +40,7 @@ pub trait CommonPropertiesExtension: Resource {
|
||||
CommonPropertiesProp::Resourcetype(self.get_resourcetype())
|
||||
}
|
||||
CommonPropertiesPropName::Displayname => {
|
||||
CommonPropertiesProp::Displayname(self.get_displayname().map(|s| s.to_string()))
|
||||
CommonPropertiesProp::Displayname(self.get_displayname().map(std::string::ToString::to_string))
|
||||
}
|
||||
CommonPropertiesPropName::CurrentUserPrincipal => {
|
||||
CommonPropertiesProp::CurrentUserPrincipal(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rustical_xml::{EnumVariants, PropName, XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone, PropName, EnumVariants)]
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone, PropName, EnumVariants)]
|
||||
#[xml(unit_variants_ident = "SyncTokenExtensionPropName")]
|
||||
pub enum SyncTokenExtensionProp {
|
||||
// Collection Synchronization (RFC 6578)
|
||||
|
||||
@@ -19,7 +19,7 @@ impl IntoResponse for InvalidDepthHeader {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Depth {
|
||||
Zero,
|
||||
One,
|
||||
@@ -29,9 +29,9 @@ pub enum Depth {
|
||||
impl ValueSerialize for Depth {
|
||||
fn serialize(&self) -> String {
|
||||
match self {
|
||||
Depth::Zero => "0",
|
||||
Depth::One => "1",
|
||||
Depth::Infinity => "infinity",
|
||||
Self::Zero => "0",
|
||||
Self::One => "1",
|
||||
Self::Infinity => "infinity",
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
@@ -55,9 +55,9 @@ impl TryFrom<&[u8]> for Depth {
|
||||
|
||||
fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
b"0" => Ok(Depth::Zero),
|
||||
b"1" => Ok(Depth::One),
|
||||
b"Infinity" | b"infinity" => Ok(Depth::Infinity),
|
||||
b"0" => Ok(Self::Zero),
|
||||
b"1" => Ok(Self::One),
|
||||
b"Infinity" | b"infinity" => Ok(Self::Infinity),
|
||||
_ => Err(InvalidDepthHeader),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl IntoResponse for InvalidOverwriteHeader {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Overwrite(pub bool);
|
||||
|
||||
impl Default for Overwrite {
|
||||
|
||||
@@ -41,13 +41,13 @@ impl XmlSerialize for UserPrivilegeSet {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub struct UserPrivilegeSet {
|
||||
privileges: HashSet<UserPrivilege>,
|
||||
}
|
||||
|
||||
impl UserPrivilegeSet {
|
||||
pub fn has(&self, privilege: &UserPrivilege) -> bool {
|
||||
#[must_use] pub fn has(&self, privilege: &UserPrivilege) -> bool {
|
||||
if (privilege == &UserPrivilege::WriteProperties
|
||||
|| privilege == &UserPrivilege::WriteContent)
|
||||
&& self.privileges.contains(&UserPrivilege::Write)
|
||||
@@ -57,13 +57,13 @@ impl UserPrivilegeSet {
|
||||
self.privileges.contains(privilege) || self.privileges.contains(&UserPrivilege::All)
|
||||
}
|
||||
|
||||
pub fn all() -> Self {
|
||||
#[must_use] pub fn all() -> Self {
|
||||
Self {
|
||||
privileges: HashSet::from([UserPrivilege::All]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn owner_only(is_owner: bool) -> Self {
|
||||
#[must_use] pub fn owner_only(is_owner: bool) -> Self {
|
||||
if is_owner {
|
||||
Self::all()
|
||||
} else {
|
||||
@@ -71,7 +71,7 @@ impl UserPrivilegeSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn owner_read(is_owner: bool) -> Self {
|
||||
#[must_use] pub fn owner_read(is_owner: bool) -> Self {
|
||||
if is_owner {
|
||||
Self::read_only()
|
||||
} else {
|
||||
@@ -79,7 +79,7 @@ impl UserPrivilegeSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn owner_write_properties(is_owner: bool) -> Self {
|
||||
#[must_use] pub fn owner_write_properties(is_owner: bool) -> Self {
|
||||
// Content is read-only but we can write properties
|
||||
if is_owner {
|
||||
Self::write_properties()
|
||||
@@ -88,7 +88,7 @@ impl UserPrivilegeSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_only() -> Self {
|
||||
#[must_use] pub fn read_only() -> Self {
|
||||
Self {
|
||||
privileges: HashSet::from([
|
||||
UserPrivilege::Read,
|
||||
@@ -98,7 +98,7 @@ impl UserPrivilegeSet {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_properties() -> Self {
|
||||
#[must_use] pub fn write_properties() -> Self {
|
||||
Self {
|
||||
privileges: HashSet::from([
|
||||
UserPrivilege::Read,
|
||||
|
||||
@@ -9,42 +9,42 @@ pub type MethodFunction<State> =
|
||||
|
||||
pub trait AxumMethods: Sized + Send + Sync + 'static {
|
||||
#[inline]
|
||||
fn report() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn report() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn get() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn post() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn post() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mkcol() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn mkcol() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mkcalendar() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn mkcalendar() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn put() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn put() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn import() -> Option<MethodFunction<Self>> {
|
||||
#[must_use] fn import() -> Option<MethodFunction<Self>> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn allow_header() -> Allow {
|
||||
#[must_use] fn allow_header() -> Allow {
|
||||
let mut allow = vec![
|
||||
Method::from_str("PROPFIND").unwrap(),
|
||||
Method::from_str("PROPPATCH").unwrap(),
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct AxumService<RS: ResourceService + AxumMethods> {
|
||||
}
|
||||
|
||||
impl<RS: ResourceService + AxumMethods> AxumService<RS> {
|
||||
pub fn new(resource_service: RS) -> Self {
|
||||
pub const fn new(resource_service: RS) -> Self {
|
||||
Self { resource_service }
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ where
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
Box::pin(async move {
|
||||
Ok(Response::builder()
|
||||
.status(StatusCode::METHOD_NOT_ALLOWED)
|
||||
|
||||
@@ -12,7 +12,7 @@ use serde::Deserialize;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(path, resource_service,))]
|
||||
pub(crate) async fn axum_route_copy<R: ResourceService>(
|
||||
pub async fn axum_route_copy<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
depth: Option<Depth>,
|
||||
|
||||
@@ -7,7 +7,7 @@ use axum_extra::TypedHeader;
|
||||
use headers::{IfMatch, IfNoneMatch};
|
||||
use http::HeaderMap;
|
||||
|
||||
pub(crate) async fn axum_route_delete<R: ResourceService>(
|
||||
pub async fn axum_route_delete<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
principal: R::Principal,
|
||||
@@ -24,8 +24,7 @@ pub(crate) async fn axum_route_delete<R: ResourceService>(
|
||||
}
|
||||
let no_trash = header_map
|
||||
.get("X-No-Trashbin")
|
||||
.map(|val| matches!(val.to_str(), Ok("1")))
|
||||
.unwrap_or(false);
|
||||
.is_some_and(|val| matches!(val.to_str(), Ok("1")));
|
||||
route_delete(
|
||||
&path,
|
||||
&principal,
|
||||
|
||||
@@ -4,8 +4,8 @@ mod mv;
|
||||
mod propfind;
|
||||
mod proppatch;
|
||||
|
||||
pub(crate) use copy::axum_route_copy;
|
||||
pub(crate) use delete::axum_route_delete;
|
||||
pub(crate) use mv::axum_route_move;
|
||||
pub(crate) use propfind::axum_route_propfind;
|
||||
pub(crate) use proppatch::axum_route_proppatch;
|
||||
pub use copy::axum_route_copy;
|
||||
pub use delete::axum_route_delete;
|
||||
pub use mv::axum_route_move;
|
||||
pub use propfind::axum_route_propfind;
|
||||
pub use proppatch::axum_route_proppatch;
|
||||
|
||||
@@ -12,7 +12,7 @@ use serde::Deserialize;
|
||||
use tracing::instrument;
|
||||
|
||||
#[instrument(skip(path, resource_service,))]
|
||||
pub(crate) async fn axum_route_move<R: ResourceService>(
|
||||
pub async fn axum_route_move<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
depth: Option<Depth>,
|
||||
|
||||
@@ -15,7 +15,7 @@ type RSMultistatus<R> = MultistatusElement<
|
||||
>;
|
||||
|
||||
#[instrument(skip(path, resource_service, puri))]
|
||||
pub(crate) async fn axum_route_propfind<R: ResourceService>(
|
||||
pub async fn axum_route_propfind<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
depth: Depth,
|
||||
@@ -36,7 +36,7 @@ pub(crate) async fn axum_route_propfind<R: ResourceService>(
|
||||
.await
|
||||
}
|
||||
|
||||
pub(crate) async fn route_propfind<R: ResourceService>(
|
||||
pub async fn route_propfind<R: ResourceService>(
|
||||
path_components: &R::PathComponents,
|
||||
path: &str,
|
||||
body: &str,
|
||||
|
||||
@@ -61,7 +61,7 @@ enum Operation<T: XmlDeserialize> {
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
struct PropertyupdateElement<T: XmlDeserialize>(#[xml(ty = "untagged", flatten)] Vec<Operation<T>>);
|
||||
|
||||
pub(crate) async fn axum_route_proppatch<R: ResourceService>(
|
||||
pub async fn axum_route_proppatch<R: ResourceService>(
|
||||
Path(path): Path<R::PathComponents>,
|
||||
State(resource_service): State<R>,
|
||||
principal: R::Principal,
|
||||
@@ -71,7 +71,7 @@ pub(crate) async fn axum_route_proppatch<R: ResourceService>(
|
||||
route_proppatch(&path, uri.path(), &body, &principal, &resource_service).await
|
||||
}
|
||||
|
||||
pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
pub async fn route_proppatch<R: ResourceService>(
|
||||
path_components: &R::PathComponents,
|
||||
path: &str,
|
||||
body: &str,
|
||||
@@ -96,7 +96,7 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
let mut props_conflict = Vec::new();
|
||||
let mut props_not_found = Vec::new();
|
||||
|
||||
for operation in operations.into_iter() {
|
||||
for operation in operations {
|
||||
match operation {
|
||||
Operation::Set(SetPropertyElement {
|
||||
prop: SetPropertyPropWrapperWrapper(properties),
|
||||
@@ -113,7 +113,7 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
Err(Error::PropReadOnly) => props_conflict
|
||||
.push((ns.map(NamespaceOwned::from), propname.to_owned())),
|
||||
Err(err) => return Err(err.into()),
|
||||
};
|
||||
}
|
||||
}
|
||||
SetPropertyPropWrapper::Invalid(invalid) => {
|
||||
let propname = invalid.tag_name();
|
||||
@@ -131,7 +131,7 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
// This happens in following cases:
|
||||
// - read-only properties with #[serde(skip_deserializing)]
|
||||
// - internal properties
|
||||
props_conflict.push(full_propname)
|
||||
props_conflict.push(full_propname);
|
||||
} else {
|
||||
props_not_found.push((None, propname));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ pub(crate) async fn route_proppatch<R: ResourceService>(
|
||||
},
|
||||
// I guess removing a nonexisting property should be successful :)
|
||||
Err(_) => props_ok.push((None, propname)),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub trait Resource: Clone + Send + 'static {
|
||||
|
||||
fn get_resourcetype(&self) -> Resourcetype;
|
||||
|
||||
fn list_props() -> Vec<(Option<Namespace<'static>>, &'static str)> {
|
||||
#[must_use] fn list_props() -> Vec<(Option<Namespace<'static>>, &'static str)> {
|
||||
Self::Prop::variant_names()
|
||||
}
|
||||
|
||||
@@ -106,13 +106,13 @@ pub trait Resource: Clone + Send + 'static {
|
||||
fn parse_propfind(
|
||||
body: &str,
|
||||
) -> Result<PropfindElement<<Self::Prop as PropName>::Names>, rustical_xml::XmlError> {
|
||||
if !body.is_empty() {
|
||||
PropfindElement::parse_str(body)
|
||||
} else {
|
||||
if body.is_empty() {
|
||||
Ok(PropfindElement {
|
||||
prop: PropfindType::Allprop,
|
||||
include: None,
|
||||
})
|
||||
} else {
|
||||
PropfindElement::parse_str(body)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ pub trait Resource: Clone + Send + 'static {
|
||||
.collect_vec();
|
||||
|
||||
return Ok(ResponseElement {
|
||||
href: path.to_owned(),
|
||||
href: path.clone(),
|
||||
propstat: vec![PropstatWrapper::TagList(PropstatElement {
|
||||
prop: TagList::from(props),
|
||||
status: StatusCode::OK,
|
||||
@@ -181,7 +181,7 @@ pub trait Resource: Clone + Send + 'static {
|
||||
}));
|
||||
}
|
||||
Ok(ResponseElement {
|
||||
href: path.to_owned(),
|
||||
href: path.clone(),
|
||||
propstat: propstats,
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
@@ -63,7 +63,7 @@ pub struct RootResourceService<PRS: ResourceService + Clone, P: Principal, PURI:
|
||||
impl<PRS: ResourceService + Clone, P: Principal, PURI: PrincipalUri>
|
||||
RootResourceService<PRS, P, PURI>
|
||||
{
|
||||
pub fn new(principal_resource_service: PRS) -> Self {
|
||||
pub const fn new(principal_resource_service: PRS) -> Self {
|
||||
Self(principal_resource_service, PhantomData, PhantomData)
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ where
|
||||
|
||||
async fn get_resource(
|
||||
&self,
|
||||
_: &(),
|
||||
(): &(),
|
||||
_show_deleted: bool,
|
||||
) -> Result<Self::Resource, Self::Error> {
|
||||
Ok(RootResource::<PRS::Resource, P>::default())
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::xml::HrefElement;
|
||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
||||
pub struct GroupMembership(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Clone)]
|
||||
#[derive(XmlDeserialize, XmlSerialize, PartialEq, Eq, Clone)]
|
||||
pub struct GroupMemberSet(#[xml(ty = "untagged", flatten)] pub Vec<HrefElement>);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
use derive_more::From;
|
||||
use rustical_xml::{XmlDeserialize, XmlSerialize};
|
||||
|
||||
#[derive(XmlDeserialize, XmlSerialize, Debug, Clone, From, PartialEq)]
|
||||
#[derive(XmlDeserialize, XmlSerialize, Debug, Clone, From, PartialEq, Eq)]
|
||||
pub struct HrefElement {
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
pub href: String,
|
||||
}
|
||||
|
||||
impl HrefElement {
|
||||
pub fn new(href: String) -> Self {
|
||||
#[must_use] pub const fn new(href: String) -> Self {
|
||||
Self { href }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ fn xml_serialize_status(
|
||||
namespaces: &HashMap<Namespace, &str>,
|
||||
writer: &mut quick_xml::Writer<&mut Vec<u8>>,
|
||||
) -> std::io::Result<()> {
|
||||
XmlSerialize::serialize(&format!("HTTP/1.1 {}", status), ns, tag, namespaces, writer)
|
||||
XmlSerialize::serialize(&format!("HTTP/1.1 {status}"), ns, tag, namespaces, writer)
|
||||
}
|
||||
|
||||
#[derive(XmlSerialize)]
|
||||
@@ -64,7 +64,7 @@ fn xml_serialize_optional_status(
|
||||
writer: &mut quick_xml::Writer<&mut Vec<u8>>,
|
||||
) -> std::io::Result<()> {
|
||||
XmlSerialize::serialize(
|
||||
&val.map(|status| format!("HTTP/1.1 {}", status)),
|
||||
&val.map(|status| format!("HTTP/1.1 {status}")),
|
||||
ns,
|
||||
tag,
|
||||
namespaces,
|
||||
|
||||
@@ -15,7 +15,7 @@ pub struct PropfindElement<PN: XmlDeserialize> {
|
||||
pub include: Option<PropElement<PN>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PropElement<PN: XmlDeserialize>(
|
||||
// valid
|
||||
pub Vec<PN>,
|
||||
@@ -82,7 +82,7 @@ impl<PN: XmlDeserialize> XmlDeserialize for PropElement<PN> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlDeserialize, PartialEq)]
|
||||
#[derive(Debug, Clone, XmlDeserialize, PartialEq, Eq)]
|
||||
pub enum PropfindType<PN: XmlDeserialize> {
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
Propname,
|
||||
|
||||
@@ -2,7 +2,7 @@ use rustical_xml::XmlSerialize;
|
||||
use strum::VariantArray;
|
||||
|
||||
// RFC 3253 section-3.1.5
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
||||
pub struct SupportedReportSet<T: XmlSerialize + 'static> {
|
||||
#[xml(flatten)]
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
@@ -10,7 +10,7 @@ pub struct SupportedReportSet<T: XmlSerialize + 'static> {
|
||||
}
|
||||
|
||||
impl<T: XmlSerialize + Clone + 'static> SupportedReportSet<T> {
|
||||
pub fn new(methods: Vec<T>) -> Self {
|
||||
#[must_use] pub fn new(methods: Vec<T>) -> Self {
|
||||
Self {
|
||||
supported_report: methods
|
||||
.into_iter()
|
||||
@@ -27,7 +27,7 @@ impl<T: XmlSerialize + Clone + 'static> SupportedReportSet<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq)]
|
||||
#[derive(Debug, Clone, XmlSerialize, PartialEq, Eq)]
|
||||
pub struct ReportWrapper<T: XmlSerialize> {
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
report: T,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use rustical_xml::XmlSerialize;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, XmlSerialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, XmlSerialize)]
|
||||
pub struct Resourcetype(#[xml(flatten, ty = "untagged")] pub &'static [ResourcetypeInner]);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, XmlSerialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, XmlSerialize)]
|
||||
pub struct ResourcetypeInner(
|
||||
#[xml(ty = "namespace")] pub Option<quick_xml::name::Namespace<'static>>,
|
||||
#[xml(ty = "tag_name")] pub &'static str,
|
||||
|
||||
@@ -2,7 +2,7 @@ use rustical_xml::{ValueDeserialize, ValueSerialize, XmlDeserialize, XmlRootTag}
|
||||
|
||||
use super::PropfindType;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum SyncLevel {
|
||||
One,
|
||||
Infinity,
|
||||
@@ -25,15 +25,15 @@ impl ValueDeserialize for SyncLevel {
|
||||
impl ValueSerialize for SyncLevel {
|
||||
fn serialize(&self) -> String {
|
||||
match self {
|
||||
SyncLevel::One => "1",
|
||||
SyncLevel::Infinity => "Infinity",
|
||||
Self::One => "1",
|
||||
Self::Infinity => "Infinity",
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
// https://datatracker.ietf.org/doc/html/rfc5323#section-5.17
|
||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct LimitElement {
|
||||
#[xml(ns = "crate::namespace::NS_DAV")]
|
||||
pub nresults: NresultsElement,
|
||||
@@ -53,7 +53,7 @@ impl From<LimitElement> for u64 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]
|
||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, Eq)]
|
||||
pub struct NresultsElement(#[xml(ty = "text")] u64);
|
||||
|
||||
#[derive(XmlDeserialize, Clone, Debug, PartialEq, XmlRootTag)]
|
||||
|
||||
@@ -6,7 +6,7 @@ use quick_xml::{
|
||||
use rustical_xml::{NamespaceOwned, XmlSerialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, From)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, From)]
|
||||
pub struct TagList(Vec<(Option<NamespaceOwned>, String)>);
|
||||
|
||||
impl XmlSerialize for TagList {
|
||||
@@ -18,13 +18,12 @@ impl XmlSerialize for TagList {
|
||||
writer: &mut quick_xml::Writer<&mut Vec<u8>>,
|
||||
) -> std::io::Result<()> {
|
||||
let prefix = ns
|
||||
.map(|ns| namespaces.get(&ns))
|
||||
.unwrap_or(None)
|
||||
.and_then(|ns| namespaces.get(&ns))
|
||||
.map(|prefix| {
|
||||
if !prefix.is_empty() {
|
||||
format!("{prefix}:")
|
||||
} else {
|
||||
if prefix.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("{prefix}:")
|
||||
}
|
||||
});
|
||||
let has_prefix = prefix.is_some();
|
||||
|
||||
Reference in New Issue
Block a user