vcard/properties/
fburl.rs

1use std::fmt::{self, Display, Formatter, Write};
2
3use validators::{Validated, ValidatedWrapper};
4
5use super::{
6    super::{
7        parameters::{
8            alternative_id::AlternativeID, any::Any, media_type::MediaType, preference::Preference,
9            property_id::PropertyID, typ::Type, Parameter,
10        },
11        values::{url, Value},
12        Set,
13    },
14    *,
15};
16
17#[derive(Clone, Debug, PartialEq, Eq, Hash)]
18#[allow(clippy::upper_case_acronyms)]
19pub struct FBURL {
20    pub typ:            Option<Type>,
21    pub media_type:     Option<MediaType>,
22    pub property_id:    Option<PropertyID>,
23    pub preference:     Option<Preference>,
24    pub alternative_id: Option<AlternativeID>,
25    pub any:            Option<Set<Any>>,
26    pub value:          url::URL,
27}
28
29impl FBURL {
30    pub fn from_url(url: url::URL) -> FBURL {
31        FBURL {
32            typ:        None,
33            media_type: None,
34
35            property_id:    None,
36            preference:     None,
37            alternative_id: None,
38            any:            None,
39            value:          url,
40        }
41    }
42}
43
44impl Property for FBURL {
45    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
46        f.write_str("FBURL")?;
47
48        macro_rules! fmt {
49            ($c:tt, $p:ident) => {
50                fmt_g!($c, Parameter, self, $p, f);
51            };
52        }
53
54        fmt!(0, typ);
55        fmt!(0, media_type);
56        fmt!(0, property_id);
57        fmt!(0, preference);
58        fmt!(0, alternative_id);
59        fmt!(2, any);
60
61        f.write_char(':')?;
62
63        Value::fmt(&self.value, f)?;
64
65        f.write_str("\r\n")?;
66
67        Ok(())
68    }
69}
70
71impl Display for FBURL {
72    fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
73        Property::fmt(self, f)
74    }
75}
76
77impl Validated for FBURL {}
78
79impl ValidatedWrapper for FBURL {
80    type Error = &'static str;
81
82    fn from_string(_from_string_input: String) -> Result<Self, Self::Error> {
83        unimplemented!();
84    }
85
86    fn from_str(_from_str_input: &str) -> Result<Self, Self::Error> {
87        unimplemented!();
88    }
89}