cloud_file_signer/
error.rs1use std::fmt::{Display, Formatter};
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash)]
7pub struct SignerError {
8 kind: SignerErrorKind,
9 message: String,
10}
11
12impl SignerError {
13 fn new(kind: SignerErrorKind, message: String) -> Self {
14 Self { kind, message }
15 }
16
17 #[must_use]
19 pub fn kind(&self) -> SignerErrorKind {
20 self.kind
21 }
22
23 #[must_use]
25 pub fn message(&self) -> &str {
26 &self.message
27 }
28
29 pub fn uri_parse_error(message: impl Into<String>) -> Self {
31 Self::new(SignerErrorKind::CloudUriParseError, message.into())
32 }
33
34 pub fn permission_not_supported(message: impl Into<String>) -> Self {
36 Self::new(SignerErrorKind::PermissionNotSupported, message.into())
37 }
38
39 pub fn other_error(message: impl Into<String>) -> Self {
41 Self::new(SignerErrorKind::Other, message.into())
42 }
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
47pub enum SignerErrorKind {
48 CloudUriParseError,
50 PermissionNotSupported,
52 Other,
54}
55
56impl Display for SignerError {
57 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
58 write!(f, "SignerError")
59 }
60}
61
62impl std::error::Error for SignerError {}