Function der_parser::ber::parse_ber_integer
source · pub fn parse_ber_integer(i: &[u8]) -> BerResult<'_>
Expand description
Read an integer value
The encoding of a boolean value shall be primitive. The contents octets shall consist of one or more octets.
To access the content, use the as_u64
,
as_u32
,
as_biguint
or
as_bigint
methods.
Remember that a BER integer has unlimited size, so these methods return Result
or Option
objects.
Examples
let empty = &b""[..];
let bytes = [0x02, 0x03, 0x01, 0x00, 0x01];
let expected = BerObject::from_obj(BerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
parse_ber_integer(&bytes),
Ok((empty, expected))
);