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
54
55
56
57
58
59
60
61
62
63
64
use rincon_core::api::auth::Credentials;
use rincon_core::api::method::{Method, Parameters, Operation, Prepare, RpcReturnType};
use rincon_core::arango::protocol::{FIELD_CODE, PATH_OPEN_AUTH};
use super::types::*;
#[derive(Debug, Clone, PartialEq)]
pub struct Authenticate {
request: AuthenticationRequest,
}
impl Authenticate {
pub fn with_credentials(credentials: &Credentials) -> Self {
Authenticate {
request: AuthenticationRequest::new(credentials.username(), credentials.password()),
}
}
pub fn with_user<N, P>(username: N, password: P) -> Self
where N: Into<String>, P: Into<String>
{
Authenticate {
request: AuthenticationRequest::new(username, password),
}
}
}
impl Method for Authenticate {
type Result = AuthenticationResponse;
const RETURN_TYPE: RpcReturnType = RpcReturnType {
result_field: None,
code_field: Some(FIELD_CODE),
};
}
impl Prepare for Authenticate {
type Content = AuthenticationRequest;
fn operation(&self) -> Operation {
Operation::Create
}
fn path(&self) -> String {
String::from(PATH_OPEN_AUTH)
}
fn parameters(&self) -> Parameters {
Parameters::empty()
}
fn header(&self) -> Parameters {
Parameters::empty()
}
fn content(&self) -> Option<&Self::Content> {
Some(&self.request)
}
}