webdav_xml/properties/
displayname.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 `displayname` property as defined in
10/// [RFC 4918](http://webdav.org/specs/rfc4918.html#PROPERTY_displayname).
11#[derive(Clone, Debug, PartialEq)]
12pub struct DisplayName(pub ByteString);
13
14impl Element for DisplayName {
15    const NAMESPACE: &'static str = DAV_NAMESPACE;
16    const PREFIX: &'static str = DAV_PREFIX;
17    const LOCAL_NAME: &'static str = "displayname";
18}
19
20impl TryFrom<&Value> for DisplayName {
21    type Error = Error;
22
23    fn try_from(value: &Value) -> Result<Self, Self::Error> {
24        Ok(Self(value.to_str()?.clone()))
25    }
26}
27
28impl From<DisplayName> for Value {
29    fn from(DisplayName(s): DisplayName) -> Value {
30        Value::Text(s)
31    }
32}