Skip to main content

vcard/value/
utc_offset.rs

1//! # UTC-offset value
2//!
3//! The decoded UTC-offset value kind.
4//!
5//! One of the forms the `TZ` property may take: a signed `hhmm` offset from UTC
6//! (RFC 6350 4.7; e.g. `-0500`), kept as its raw text. `TZ` may instead be plain
7//! text or a URI, decoded as the corresponding kinds.
8
9use alloc::{borrow::Cow, string::String};
10
11/// A decoded UTC-offset value (signed `hhmm`), kept as its raw text.
12#[derive(Clone, Debug, Default, PartialEq, Eq)]
13pub struct VcardUtcOffset<'a>(pub Cow<'a, str>);
14
15impl<'a> From<&'a str> for VcardUtcOffset<'a> {
16    fn from(value: &'a str) -> Self {
17        Self(Cow::Borrowed(value))
18    }
19}
20
21impl From<String> for VcardUtcOffset<'_> {
22    fn from(value: String) -> Self {
23        Self(Cow::Owned(value))
24    }
25}
26
27impl<'a> From<Cow<'a, str>> for VcardUtcOffset<'a> {
28    fn from(value: Cow<'a, str>) -> Self {
29        Self(value)
30    }
31}