Skip to main content

ical/value/
cal_address.rs

1//! # Calendar-address value
2//!
3//! The decoded calendar-address value kind.
4//!
5//! Backs `ORGANIZER`, `ATTENDEE` and `CALENDAR-ADDRESS` (RFC 5545 3.3.3): a URI
6//! identifying a calendar user, most commonly a `mailto:` address. The reference
7//! is kept verbatim as a string; the crate does not parse or validate it.
8
9use alloc::{borrow::Cow, string::String};
10
11/// A decoded calendar-address value (a URI, usually `mailto:`), kept verbatim.
12#[derive(Clone, Debug, Default, PartialEq, Eq)]
13pub struct IcalCalAddress<'a>(pub Cow<'a, str>);
14
15impl<'a> From<&'a str> for IcalCalAddress<'a> {
16    fn from(value: &'a str) -> Self {
17        Self(Cow::Borrowed(value))
18    }
19}
20
21impl From<String> for IcalCalAddress<'_> {
22    fn from(value: String) -> Self {
23        Self(Cow::Owned(value))
24    }
25}
26
27impl<'a> From<Cow<'a, str>> for IcalCalAddress<'a> {
28    fn from(value: Cow<'a, str>) -> Self {
29        Self(value)
30    }
31}