Skip to main content

vcard/value/
language.rs

1//! # Language-tag value
2//!
3//! The decoded language-tag value kind.
4//!
5//! Backs the `LANG` property (RFC 6350 4.8), whose value is an RFC 5646
6//! language tag (e.g. `en`, `fr-CA`). The tag is kept verbatim; the crate does
7//! not parse its subtags.
8
9use alloc::{borrow::Cow, string::String};
10
11/// A decoded RFC 5646 language tag, kept verbatim.
12#[derive(Clone, Debug, Default, PartialEq, Eq)]
13pub struct VcardLanguageTag<'a>(pub Cow<'a, str>);
14
15impl<'a> From<&'a str> for VcardLanguageTag<'a> {
16    fn from(value: &'a str) -> Self {
17        Self(Cow::Borrowed(value))
18    }
19}
20
21impl From<String> for VcardLanguageTag<'_> {
22    fn from(value: String) -> Self {
23        Self(Cow::Owned(value))
24    }
25}
26
27impl<'a> From<Cow<'a, str>> for VcardLanguageTag<'a> {
28    fn from(value: Cow<'a, str>) -> Self {
29        Self(value)
30    }
31}