mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 17:02:32 +00:00
A little more preparation for new DAV Push spec
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use actix_web::{FromRequest, HttpRequest, ResponseError, http::StatusCode};
|
||||
use futures_util::future::{Ready, err, ok};
|
||||
use rustical_xml::ValueSerialize;
|
||||
use rustical_xml::{ValueDeserialize, ValueSerialize, XmlError};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -25,12 +25,25 @@ impl ValueSerialize for Depth {
|
||||
match self {
|
||||
Depth::Zero => "0",
|
||||
Depth::One => "1",
|
||||
Depth::Infinity => "Infinity",
|
||||
Depth::Infinity => "infinity",
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl ValueDeserialize for Depth {
|
||||
fn deserialize(val: &str) -> Result<Self, XmlError> {
|
||||
match val {
|
||||
"0" => Ok(Self::Zero),
|
||||
"1" => Ok(Self::One),
|
||||
"infinity" | "Infinity" => Ok(Self::Infinity),
|
||||
_ => Err(XmlError::InvalidVariant(
|
||||
"Invalid value for depth".to_owned(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<&[u8]> for Depth {
|
||||
type Error = InvalidDepthHeader;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user