diff --git a/der/src/error.rs b/der/src/error.rs index aeb10b8b9..215daf159 100644 --- a/der/src/error.rs +++ b/der/src/error.rs @@ -15,6 +15,21 @@ use crate::pem; pub type Result = core::result::Result; /// Error type. +/// +/// ## Example +/// ``` +/// use der::{Decode, ErrorKind, Reader}; +/// +/// struct MyDecodable; +/// +/// impl<'a> Decode<'a> for MyDecodable { +/// type Error = der::Error; +/// +/// fn decode>(reader: &mut R) -> Result { +/// Err(reader.error(ErrorKind::OidMalformed)) +/// } +/// } +/// ``` #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Error { /// Kind of error. @@ -162,6 +177,15 @@ impl From for Error { } /// Error type. +/// +/// # Example +/// ``` +/// use der::{asn1::OctetStringRef, Decode, ErrorKind}; +/// +/// let err = <&OctetStringRef>::from_der(&[0x04, 0x80, 0x00]).unwrap_err(); +/// +/// assert_eq!(err.kind(), ErrorKind::IndefiniteLength); +/// ``` #[derive(Copy, Clone, Debug, Eq, PartialEq)] #[non_exhaustive] pub enum ErrorKind {