x509_ocsp/
builder.rs

1//! OCSP builder module
2
3use alloc::fmt;
4
5mod request;
6mod response;
7
8pub use self::request::OcspRequestBuilder;
9pub use self::response::OcspResponseBuilder;
10
11/// Error type
12#[derive(Debug)]
13pub enum Error {
14    /// ASN.1 DER-related errors
15    Asn1(der::Error),
16
17    /// Public key errors
18    PublicKey(spki::Error),
19
20    /// Signing errors
21    Signature(signature::Error),
22}
23
24#[cfg(feature = "std")]
25impl std::error::Error for Error {}
26
27impl fmt::Display for Error {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        match self {
30            Error::Asn1(err) => write!(f, "ASN.1 error: {}", err),
31            Error::PublicKey(err) => write!(f, "public key error: {}", err),
32            Error::Signature(err) => write!(f, "signature error: {}", err),
33        }
34    }
35}
36
37impl From<der::Error> for Error {
38    fn from(other: der::Error) -> Self {
39        Self::Asn1(other)
40    }
41}
42
43impl From<spki::Error> for Error {
44    fn from(other: spki::Error) -> Self {
45        Self::PublicKey(other)
46    }
47}
48
49impl From<signature::Error> for Error {
50    fn from(other: signature::Error) -> Self {
51        Self::Signature(other)
52    }
53}