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
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
pub type SignResult<T> = std::result::Result<T, SignerError>;
pub type TokenReaderResult<T> = std::result::Result<T, TokenReaderError>;
#[derive(Error, Debug)]
pub enum Error {
#[error("token acquisition failed : {0}")]
TokenReader(#[from] TokenReaderError),
#[error("OAuth sign failed : {0}")]
Signer(#[from] SignerError),
#[error("request failed : {0}")]
Reqwest(#[from] reqwest::Error),
}
#[derive(Error, Debug, Clone)]
pub enum SignerError {
#[error("unknown oauth parameter : {0}")]
UnknownParameter(String),
#[error("specified parameter {0} could not be configured via the reqwest parameters.")]
UnconfigurableParameter(String),
#[error("invalid oauth_timestamp, must be u64, but {0} is not compatible.")]
InvalidTimestamp(String),
#[error("invalid oauth_version, must be 1.0 or just empty, but specified {0}.")]
InvalidVersion(String),
}
#[derive(Error, Debug, Clone)]
pub enum TokenReaderError {
#[error("the response has malformed format: key {0} is not found in response {1}")]
TokenKeyNotFound(&'static str, String),
}