dav: remove anyhow dependency

This commit is contained in:
Lennart
2024-10-31 18:15:44 +01:00
parent 9db7f629f2
commit 764f9401ac
4 changed files with 2 additions and 8 deletions

1
Cargo.lock generated
View File

@@ -2590,7 +2590,6 @@ name = "rustical_dav"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"anyhow",
"async-trait", "async-trait",
"derive_more 1.0.0", "derive_more 1.0.0",
"futures-util", "futures-util",

View File

@@ -8,7 +8,6 @@ publish = false
[dependencies] [dependencies]
actix-web = { workspace = true } actix-web = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true } async-trait = { workspace = true }
futures-util = { workspace = true } futures-util = { workspace = true }
quick-xml = { workspace = true } quick-xml = { workspace = true }

View File

@@ -25,16 +25,12 @@ pub enum Error {
#[error(transparent)] #[error(transparent)]
XmlSerializationError(#[from] quick_xml::SeError), XmlSerializationError(#[from] quick_xml::SeError),
#[error("Internal server error")]
Other(#[from] anyhow::Error),
} }
impl actix_web::error::ResponseError for Error { impl actix_web::error::ResponseError for Error {
fn status_code(&self) -> StatusCode { fn status_code(&self) -> StatusCode {
match self { match self {
Self::InternalError => StatusCode::INTERNAL_SERVER_ERROR, Self::InternalError => StatusCode::INTERNAL_SERVER_ERROR,
Self::Other(_) => StatusCode::INTERNAL_SERVER_ERROR,
Self::NotFound => StatusCode::NOT_FOUND, Self::NotFound => StatusCode::NOT_FOUND,
Self::BadRequest(_) => StatusCode::BAD_REQUEST, Self::BadRequest(_) => StatusCode::BAD_REQUEST,
Self::Unauthorized => StatusCode::UNAUTHORIZED, Self::Unauthorized => StatusCode::UNAUTHORIZED,

View File

@@ -18,7 +18,7 @@ use strum::VariantNames;
pub trait Resource: Clone { pub trait Resource: Clone {
type PropName: FromStr + VariantNames + Clone; type PropName: FromStr + VariantNames + Clone;
type Prop: Serialize + for<'de> Deserialize<'de> + fmt::Debug + InvalidProperty; type Prop: Serialize + for<'de> Deserialize<'de> + fmt::Debug + InvalidProperty;
type Error: ResponseError + From<crate::Error> + From<anyhow::Error>; type Error: ResponseError + From<crate::Error>;
fn list_props() -> &'static [&'static str] { fn list_props() -> &'static [&'static str] {
Self::PropName::VARIANTS Self::PropName::VARIANTS
@@ -139,7 +139,7 @@ pub trait ResourceService: Sized + 'static {
type MemberType: Resource<Error = Self::Error>; type MemberType: Resource<Error = Self::Error>;
type PathComponents: for<'de> Deserialize<'de> + Sized + Clone + 'static; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String) type PathComponents: for<'de> Deserialize<'de> + Sized + Clone + 'static; // defines how the resource URI maps to parameters, i.e. /{principal}/{calendar} -> (String, String)
type Resource: Resource<Error = Self::Error>; type Resource: Resource<Error = Self::Error>;
type Error: ResponseError + From<crate::Error> + From<anyhow::Error>; type Error: ResponseError + From<crate::Error>;
async fn new( async fn new(
req: &HttpRequest, req: &HttpRequest,