Struct bcder::oid::Oid

source ·
pub struct Oid<T: AsRef<[u8]> = Bytes>(pub T);
Expand description

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.

Tuple Fields§

§0: T

Implementations§

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.

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.

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.

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.

Skip over an object identifier if it matches self.

Returns a value encoder for the value using the natural tag.

Returns a value encoder for the value using the given tag.

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§

Converts this type into a shared reference of the (usually inferred) input type.
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The natural tag of an encoded value of this type.
Returns the length of the encoded content of this type.
Writes the encoded content to a writer.
Encodes the value to bytes (useful when you need to sign a structure)
Returns a value encoder for this content using the natural tag. Read more
Returns a value encoder for this content using the given tag. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.