1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use url::UrlQuery;
use url::form_urlencoded::Serializer;

#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Privacy {
    Public,
    Private
}

impl Default for Privacy {
    fn default() -> Self {
        Privacy::Public
    }
}

pub trait AppendToQueryParams {
    fn append_to(&self, query: &mut Serializer<UrlQuery>);
}

#[cfg(test)]
mod test {
    use super::*;
    use serde_json::{self};

    #[test]
    fn unit_serialize_privacy_private() {
        let actual = serde_json::to_string(&Privacy::Private).unwrap();
        let expected = "\"private\"";
        assert_eq!(actual, expected);
    }
}