blob: 6f60c8d77d27751964420a9b435b2281a7371632 (
plain) (
blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
use super::Call;
use std::collections::BTreeMap;
// Contains login information. Used to create an API session.
#[derive(Clone, Debug)]
pub(crate) struct Login<'a> {
pub(crate) user: &'a str,
pub(crate) pass: &'a str,
pub(crate) case_insensitive: bool,
}
impl From<Login<'_>> for xmlrpc::Value {
fn from(login: Login<'_>) -> Self {
let mut map = BTreeMap::new();
map.insert("user".into(), login.user.into());
map.insert("pass".into(), login.pass.into());
map.insert("case-insensitive".into(), login.case_insensitive.into());
xmlrpc::Value::Struct(map)
}
}
impl Call for Login<'_> {
fn method_name(&self) -> String {
String::from("account.login")
}
fn expected(&self) -> Vec<i32> {
vec![1000]
}
}
// Contains no information. This just signals to the server
// that it should end the session.
#[derive(Clone, Debug)]
pub(crate) struct Logout;
impl From<Logout> for xmlrpc::Value {
fn from(_logout: Logout) -> Self {
xmlrpc::Value::Nil
}
}
impl Call for Logout {
fn method_name(&self) -> String {
String::from("account.logout")
}
fn expected(&self) -> Vec<i32> {
vec![1500]
}
}
|