webdav_xml/elements/
responsedescription.rs

1// SPDX-FileCopyrightText: d-k-bo <d-k-bo@mailbox.org>
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5use bytestring::ByteString;
6
7use crate::{Element, Error, Value, DAV_NAMESPACE, DAV_PREFIX};
8
9/// The `responsedescription` XML element as defined in [RFC 4918](http://webdav.org/specs/rfc4918.html#ELEMENT_responsedescription).
10#[derive(Clone, Debug, PartialEq)]
11pub struct ResponseDescription(pub ByteString);
12
13impl Element for ResponseDescription {
14    const NAMESPACE: &'static str = DAV_NAMESPACE;
15    const PREFIX: &'static str = DAV_PREFIX;
16    const LOCAL_NAME: &'static str = "responsedescription";
17}
18
19impl TryFrom<&Value> for ResponseDescription {
20    type Error = Error;
21
22    fn try_from(value: &Value) -> Result<Self, Self::Error> {
23        Ok(Self(value.to_str()?.to_owned()))
24    }
25}
26
27impl From<ResponseDescription> for Value {
28    fn from(ResponseDescription(s): ResponseDescription) -> Value {
29        Value::Text(s)
30    }
31}
32
33impl<S: Into<ByteString>> From<S> for ResponseDescription {
34    fn from(s: S) -> Self {
35        ResponseDescription(s.into())
36    }
37}