Struct bcder::int::Unsigned [−][src]
pub struct Unsigned(_);
Expand description
A BER encoded unsigned integer.
As integers are variable length in BER, this type is just a simple wrapper
atop the underlying Bytes
value containing the raw content. It
guarantees that the wrapped integer is greater or equal to 0. This equals
an integer defined as INTEGER (0..MAX)
in ASN.1.
If you need a integer without any restrictions, you can use Integer
. If
you have even stricter range restrictions, you can also use the methods
provided on the content types to decode into Rust’s primitive integer
types such as u16
.
BER Encoding
In BER, an INTEGER is encoded as a primitive value with the content octets providing a variable-length, big-endian, two‘s complement byte sequence of that integer. Thus, the most-significant bit of the first octet serves as the sign bit and, for an unsigned integer, has to be unset.
Implementations
Constructs Unsigned
by copying from a &[u8]
.
Errors
Will return Error::Malformed
if the given slice is empty.
Constructs Unsigned
from Bytes
, copying only if needed.
Errors
Will return Error::Malformed
if the given Bytes value is empty.
Trades the integer into a bytes value with the raw content octets.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
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
Returns a value encoder for a reference using the natural tag.
Returns a value encoder for a reference using the given tag.
Auto Trait Implementations
impl RefUnwindSafe for Unsigned
impl UnwindSafe for Unsigned
Blanket Implementations
Mutably borrows from an owned value. Read more