der_parser/error.rs
1//! Error type for BER/DER parsers
2
3use crate::ber::BerObject;
4use crate::der::DerObject;
5use nom::IResult;
6
7pub use asn1_rs::{DerConstraint, Error};
8
9pub type BerError = Error;
10
11// pub use asn1_rs::Result;
12
13/// Holds the result of parsing functions
14///
15/// `O` is the output type, and defaults to a `BerObject`.
16///
17/// Note that this type is also a `Result`, so usual functions (`map`, `unwrap` etc.) are available.
18///
19/// This type is a wrapper around nom's IResult type
20pub type BerResult<'a, O = BerObject<'a>> = IResult<&'a [u8], O, BerError>;
21
22/// Holds the result of parsing functions (DER)
23///
24/// Note that this type is also a `Result`, so usual functions (`map`, `unwrap` etc.) are available.
25pub type DerResult<'a> = BerResult<'a, DerObject<'a>>;
26
27#[cfg(all(test, feature = "std"))]
28mod tests {
29 use super::*;
30 use std::boxed::Box;
31 use std::error::Error;
32
33 #[test]
34 fn test_unwrap_bererror() {
35 let e = BerError::IntegerTooLarge;
36 // println!("{}", e);
37 let _: Result<(), Box<dyn Error>> = Err(Box::new(e));
38 }
39}