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
use super::*;
#[derive(Copy, Clone, Debug, Default)]
pub struct Identity;
#[derive(Clone, Debug)]
pub struct IdentitySign(pub String);
impl SignatureMethod for Identity {
type Sign = IdentitySign;
fn sign_with(
self,
_consumer_secret: impl Display,
_token_secret: Option<impl Display>,
) -> IdentitySign {
IdentitySign(String::new())
}
}
impl Sign for IdentitySign {
type Signature = String;
fn get_signature_method_name(&self) -> &'static str {
"IDENTITY"
}
fn request_method(&mut self, method: &str) {
self.0.push_str(method);
self.0.push('&');
}
fn uri(&mut self, uri: impl Display) {
write!(self.0, "{}", uri).unwrap();
self.0.push('&');
}
fn parameter(&mut self, key: &str, value: impl Display) {
self.0.push_str(key);
self.0.push_str("%3D");
write!(self.0, "{}", value).unwrap();
}
fn delimiter(&mut self) {
self.0.push_str("%26");
}
fn finish(self) -> String {
self.0
}
}