Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Error for OidParseError #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/asn1_types/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ use alloc::vec::Vec;
use core::{
convert::TryFrom, fmt, iter::FusedIterator, marker::PhantomData, ops::Shl, str::FromStr,
};
use displaydoc::Display;
use num_traits::Num;

/// An error for OID parsing functions.
#[derive(Debug)]
#[derive(Debug, Display)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
pub enum OidParseError {
/// Non-relative OIDs must be at least 2 components long and relative OIDs must not be empty
TooShort,
/// Signalizes that the first or second component is too large.
/// The first must be within the range 0 to 6 (inclusive).
/// The second component must be less than 40.

/// The first OID component must be < 7 and the second must be < 40
FirstComponentsTooLarge,

/// OID component is not an integer
ParseIntError,
}

Expand All @@ -31,7 +35,6 @@ pub enum OidParseError {
/// create oids. For example `oid!(1.2.44.233)` or `oid!(rel 44.233)`
/// for relative oids. See the [module documentation](index.html) for more information.
#[derive(Hash, PartialEq, Eq, Clone)]

pub struct Oid<'a> {
asn1: Cow<'a, [u8]>,
relative: bool,
Expand Down
Loading