webdav_xml/properties/
getcontentlength.rs1use crate::{Element, Error, Value, DAV_NAMESPACE, DAV_PREFIX};
6
7#[derive(Clone, Copy, Debug, PartialEq)]
10pub struct ContentLength(pub u64);
11
12impl Element for ContentLength {
13 const NAMESPACE: &'static str = DAV_NAMESPACE;
14 const PREFIX: &'static str = DAV_PREFIX;
15 const LOCAL_NAME: &'static str = "getcontentlength";
16}
17
18impl TryFrom<&Value> for ContentLength {
19 type Error = Error;
20
21 fn try_from(value: &Value) -> Result<Self, Self::Error> {
22 value.to_str()?.parse().map(Self).map_err(Error::other)
23 }
24}
25
26impl From<ContentLength> for Value {
27 fn from(ContentLength(len): ContentLength) -> Value {
28 len.to_string().into()
29 }
30}