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 std::fmt::Display;
use super::*;
#[derive(Copy, Clone, Debug, Default)]
pub struct Plaintext;
#[derive(Clone, Debug)]
pub struct PlaintextSign(String);
impl SignatureMethod for Plaintext {
type Sign = PlaintextSign;
fn sign_with(
self,
consumer_secret: impl Display,
token_secret: Option<impl Display>,
) -> PlaintextSign {
let mut key = String::with_capacity(128);
write_signing_key(&mut key, consumer_secret, token_secret);
PlaintextSign(key)
}
}
impl Sign for PlaintextSign {
type Signature = String;
fn get_signature_method_name(&self) -> &'static str {
"PLAINTEXT"
}
fn request_method(&mut self, _method: &str) {}
fn uri(&mut self, _uri: impl Display) {}
fn parameter(&mut self, _key: &str, _value: impl Display) {}
fn delimiter(&mut self) {}
fn finish(self) -> String {
self.0
}
}