webdav_xml/properties/
getcontentlanguage.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 `getcontentlanguage` property as defined in
10/// [RFC 4918](http://webdav.org/specs/rfc4918.html#PROPERTY_getcontentlanguage).
11#[derive(Clone, Debug, PartialEq)]
12pub struct ContentLanguage(pub ByteString);
13
14impl Element for ContentLanguage {
15    const NAMESPACE: &'static str = DAV_NAMESPACE;
16    const PREFIX: &'static str = DAV_PREFIX;
17    const LOCAL_NAME: &'static str = "getcontentlanguage";
18}
19
20impl TryFrom<&Value> for ContentLanguage {
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<ContentLanguage> for Value {
29    fn from(ContentLanguage(s): ContentLanguage) -> Value {
30        Value::Text(s)
31    }
32}