rustical_dav: Make actix-web a completely optional dependency

This commit is contained in:
Lennart
2025-06-02 21:58:46 +02:00
parent 05ff2536f6
commit 9836a696ad
10 changed files with 87 additions and 36 deletions

View File

@@ -1,5 +1,7 @@
use actix_web::{FromRequest, HttpRequest, ResponseError, http::StatusCode};
#[cfg(feature = "actix")]
use actix_web::{HttpRequest, ResponseError};
use futures_util::future::{Ready, err, ok};
use http::StatusCode;
use rustical_xml::{ValueDeserialize, ValueSerialize, XmlError};
use thiserror::Error;
@@ -7,6 +9,7 @@ use thiserror::Error;
#[error("Invalid Depth header")]
pub struct InvalidDepthHeader;
#[cfg(feature = "actix")]
impl ResponseError for InvalidDepthHeader {
fn status_code(&self) -> actix_web::http::StatusCode {
StatusCode::BAD_REQUEST
@@ -57,7 +60,8 @@ impl TryFrom<&[u8]> for Depth {
}
}
impl FromRequest for Depth {
#[cfg(feature = "actix")]
impl actix_web::FromRequest for Depth {
type Error = InvalidDepthHeader;
type Future = Ready<Result<Self, Self::Error>>;