vcard-rs 0.3.1

vCard parser, validator, editor, merger and builder library
Documentation
//! # Text values
//!
//! The decoded text value kinds: a single text, and a comma-separated text
//! list.
//!
//! These back the bulk of RFC 6350 properties whose value is plain text (the
//! TEXT value type, RFC 6350 4.1): `FN`, `TITLE`, `ROLE`, `NOTE`, `PRODID`,
//! `KIND`, `TEL`, `EMAIL`, ... for [`VcardText`], and `NICKNAME` /
//! `CATEGORIES` for [`VcardTextList`].
//!
//! Carrying no wire name, the same value type round-trips through any property
//! that shares the kind.

use alloc::{borrow::Cow, string::String, vec::Vec};

/// A single decoded text value (unescaped).
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct VcardText<'a>(pub Cow<'a, str>);

impl<'a> From<&'a str> for VcardText<'a> {
    fn from(value: &'a str) -> Self {
        Self(Cow::Borrowed(value))
    }
}

impl From<String> for VcardText<'_> {
    fn from(value: String) -> Self {
        Self(Cow::Owned(value))
    }
}

impl<'a> From<Cow<'a, str>> for VcardText<'a> {
    fn from(value: Cow<'a, str>) -> Self {
        Self(value)
    }
}

/// A decoded comma-separated text list (each item unescaped).
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct VcardTextList<'a>(pub Vec<Cow<'a, str>>);

impl<'a> From<Vec<Cow<'a, str>>> for VcardTextList<'a> {
    fn from(values: Vec<Cow<'a, str>>) -> Self {
        Self(values)
    }
}