[−][src]Struct bcder::oid::Oid
An object identifer.
Object identifiers are globally unique, hierarchical values that are used to identify objects or their type. When written, they are presented as a sequence of integers separated by dots such as ‘1.3.6.1.5.5.7.1’ or with the integers separated by white space and enclosed in curly braces such as ‘{ 1 3 6 1 5 5 7 1 }’. Individual integers or sequences of integers can also be given names which then are used instead of the integers.
Values of this type keep a single object identifer in its BER encoding,
i.e., in some form of byte sequence. Because different representations
may be useful, the type is actually generic over something that can
become a reference to a bytes slice. Parsing is only defined for Bytes
values, though.
The only use for object identifiers currently is to compare them to
predefined values. For this purpose, you typically define your known
object identifiers in a oid
submodule as contants of
Oid<&'static [u8]>
– or its type alias ConstOid
. This is also the
reason why the wrapped value is pub
for now. This will change once
const fn
is stable.
Unfortunately, there is currently no proc macro to generate the object
identifier constants in the code. Instead, the crate ships with a
mkoid
binary which accepts object identifiers in ‘dot integer’ notation
and produces the u8
array for their encoded value. You can install
this binary via cargo install ber
.
Methods
impl Oid<Bytes>
[src]
pub fn skip_in<S: Source>(cons: &mut Constructed<S>) -> Result<(), S::Err>
[src]
Skips over an object identifier value.
If the source has reached its end, if the next value does not have
the Tag::OID
, or if it is not a primitive value, returns a malformed
error.
pub fn skip_opt_in<S: Source>(
cons: &mut Constructed<S>
) -> Result<Option<()>, S::Err>
[src]
cons: &mut Constructed<S>
) -> Result<Option<()>, S::Err>
Skips over an optional object identifier value.
If the source has reached its end of if the next value does not have
the Tag::OID
, returns Ok(None)
. If the next value has the right
tag but is not a primitive value, returns a malformed error.
pub fn take_from<S: Source>(
constructed: &mut Constructed<S>
) -> Result<Self, S::Err>
[src]
constructed: &mut Constructed<S>
) -> Result<Self, S::Err>
Takes an object identifier value from the source.
If the source has reached its end, if the next value does not have
the Tag::OID
, or if it is not a primitive value, returns a malformed
error.
pub fn take_opt_from<S: Source>(
constructed: &mut Constructed<S>
) -> Result<Option<Self>, S::Err>
[src]
constructed: &mut Constructed<S>
) -> Result<Option<Self>, S::Err>
Takes an optional object identifier value from the source.
If the source has reached its end of if the next value does not have
the Tag::OID
, returns Ok(None)
. If the next value has the right
tag but is not a primitive value, returns a malformed error.
impl<T: AsRef<[u8]>> Oid<T>
[src]
pub fn skip_if<S: Source>(
&self,
constructed: &mut Constructed<S>
) -> Result<(), S::Err>
[src]
&self,
constructed: &mut Constructed<S>
) -> Result<(), S::Err>
Skip over an object identifier if it matches self
.
impl<T: AsRef<[u8]>> Oid<T>
[src]
ⓘImportant traits for Iter<'a>pub fn iter(&self) -> Iter
[src]
Returns an iterator to the components of this object identifiers.
Panics
The returned identifier will eventually panic if self
does not
contain a correctly encoded object identifier.
Trait Implementations
impl<T: AsRef<[u8]>> AsRef<[u8]> for Oid<T>
[src]
impl<T: Clone + AsRef<[u8]>> Clone for Oid<T>
[src]
impl<T: Debug + AsRef<[u8]>> Debug for Oid<T>
[src]
impl<T: AsRef<[u8]>> Display for Oid<T>
[src]
impl<T: AsRef<[u8]>> Eq for Oid<T>
[src]
impl<T: AsRef<[u8]>> Hash for Oid<T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: AsRef<[u8]>, U: AsRef<[u8]>> PartialEq<Oid<U>> for Oid<T>
[src]
impl<T: AsRef<[u8]>> PrimitiveContent for Oid<T>
[src]
const TAG: Tag
[src]
fn encoded_len(&self, _: Mode) -> usize
[src]
fn write_encoded<W: Write>(&self, _: Mode, target: &mut W) -> Result<(), Error>
[src]
fn to_encoded_bytes(&self, mode: Mode) -> Bytes
[src]
fn encode(self) -> Primitive<Self>
[src]
fn encode_as(self, tag: Tag) -> Primitive<Self>
[src]
fn encode_ref(&self) -> Primitive<&Self>
[src]
fn encode_ref_as(&self, tag: Tag) -> Primitive<&Self>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Oid<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Oid<T> where
T: Send,
T: Send,
impl<T> Sync for Oid<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Oid<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Oid<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,