webdav_xml/properties/
getlastmodified.rs

1// SPDX-FileCopyrightText: d-k-bo <d-k-bo@mailbox.org>
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use httpdate::HttpDate;
6
7use crate::{Element, Error, Value, DAV_NAMESPACE, DAV_PREFIX};
8
9/// The `getlastmodified` property as defined in
10/// [RFC 4918](http://webdav.org/specs/rfc4918.html#PROPERTY_getlastmodified).
11#[derive(Clone, Debug, PartialEq)]
12pub struct LastModified(pub HttpDate);
13
14impl Element for LastModified {
15    const NAMESPACE: &'static str = DAV_NAMESPACE;
16    const PREFIX: &'static str = DAV_PREFIX;
17    const LOCAL_NAME: &'static str = "getlastmodified";
18}
19
20impl TryFrom<&Value> for LastModified {
21    type Error = Error;
22
23    fn try_from(value: &Value) -> Result<Self, Self::Error> {
24        value.to_str()?.parse().map(Self).map_err(Error::other)
25    }
26}
27
28impl From<LastModified> for Value {
29    fn from(LastModified(date): LastModified) -> Value {
30        date.to_string().into()
31    }
32}