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
33
34
35
36
use std::borrow::Cow;
use std::collections::HashMap;
use user;
mod response;
mod from_json;
pub use common::response::*;
pub use common::from_json::*;
pub type ParamList<'a> = HashMap<Cow<'a, str>, Cow<'a, str>>;
pub fn add_param<'a, K, V>(list: &mut ParamList<'a>, key: K, value: V) -> Option<Cow<'a, str>>
where K: Into<Cow<'a, str>>,
V: Into<Cow<'a, str>>
{
list.insert(key.into(), value.into())
}
pub fn add_name_param<'a>(list: &mut ParamList<'a>, id: &user::UserID<'a>) -> Option<Cow<'a, str>> {
match *id {
user::UserID::ID(id) => add_param(list, "user_id", id.to_string()),
user::UserID::ScreenName(name) => add_param(list, "screen_name", name),
}
}
pub type WebResponse<T> = Result<Response<T>, ::error::Error>;