http_msgsign_draft/
errors.rs1use http_content_digest::errors::ExtractHeaderError;
2
3#[derive(Debug, thiserror::Error)]
4#[error("Invalid `Digest` header format. {reason}")]
5pub struct InvalidDigestDataFormat {
6 pub reason: &'static str,
7}
8
9impl From<InvalidDigestDataFormat> for ExtractHeaderError {
10 fn from(value: InvalidDigestDataFormat) -> Self {
11 Self::InvalidHeaderValue(Box::new(value))
12 }
13}
14
15#[derive(Debug, thiserror::Error)]
16pub enum SignatureInputError {
17 #[error("No `Signature` / `Authorization` header was found.")]
18 NotExist,
19 #[error(transparent)]
20 InvalidValue(#[from] InvalidValue),
21 #[error("{0} is required but not defined.")]
22 RequireParameter(&'static str),
23}
24
25#[derive(Debug, thiserror::Error)]
26pub enum SignatureParamsError {
27 #[error(transparent)]
28 InvalidHeaderName(#[from] http::Error),
29}
30
31#[derive(Debug, thiserror::Error)]
32pub enum HttpPayloadSeekError {
33 #[error("`{incompatible}` cannot be applied to {target}.")]
34 InvalidTarget {
35 target: &'static str,
36 incompatible: &'static str,
37 },
38 #[error(transparent)]
39 InvalidValue(#[from] InvalidValue),
40}
41
42#[derive(Debug, thiserror::Error)]
43pub enum InvalidValue {
44 #[error("`String` type was expected, but another data format is used.")]
45 String,
46 #[error("`Integer` type was expected, but another data format is used.")]
47 Integer,
48 #[error("An array with some value was expected, but there was no content.")]
49 NonEmptyArray,
50}
51
52#[derive(Debug, thiserror::Error)]
53pub enum SignError {
54 #[error(transparent)]
55 SeekPayload(#[from] HttpPayloadSeekError),
56}
57
58#[derive(Debug, thiserror::Error)]
59pub enum VerificationError {
60 #[error(transparent)]
61 ParseSignature(#[from] SignatureInputError),
62 #[error(transparent)]
63 SeekPayload(#[from] HttpPayloadSeekError),
64 #[error("signature unverified.")]
65 Unverified,
66 #[error(transparent)]
67 Crypto(Box<dyn std::error::Error + Sync + Send>),
68}