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§
source§impl Unsigned
impl Unsigned
pub fn take_from<S: Source>(
cons: &mut Constructed<'_, S>
) -> Result<Self, S::Err>
pub fn from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<Self, S::Err>
pub fn u8_from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<u8, S::Err>
pub fn u16_from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<u16, S::Err>
pub fn u32_from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<u32, S::Err>
pub fn u64_from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<u64, S::Err>
pub fn u128_from_primitive<S: Source>(
prim: &mut Primitive<'_, S>
) -> Result<u128, S::Err>
Trait Implementations§
source§impl Ord for Unsigned
impl Ord for Unsigned
source§impl PartialOrd<Unsigned> for Unsigned
impl PartialOrd<Unsigned> for Unsigned
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more