Struct bcder::int::Integer [−][src]
pub struct Integer(_);
Expand description
A BER encoded integer.
As integers are variable length in BER, this type is just a simple wrapper
atop the underlying Bytes
value containing the raw content. A value of
this type is a signed integer. If a value is defined as an unsigned
integer, i.e., as INTEGER (0..MAX)
, you should use the sibling type
Unsigned
instead.
In addition to these two generic types, the content decoders also provide
methods to parse integers into native integer types such as i8
. If the
range of such a type is obviously enough, you might want to consider
using these methods instead.
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.
Implementations
Takes a single signed integer from the beginning of an encoded value.
This requires the next value in cons
to be a primitive value with
a correctly encoded signed integer.
Constructs a signed integer from the content of a primitive value.
Constructs an i8
from the content of a primitive value.
Constructs an i16
from the content of a primitive value.
Constructs an i32
from the content of a primitive value.
Constructs an i64
from the content of a primitive value.
Constructs an i128
from the content of a primitive value.
Trades the integer into a bytes value with the raw content octets.
Returns whether the integer is positive.
Also returns false
if the number is zero.
Returns whether the integer is negative.
Also returns false
if the number is zero.
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 Integer
impl UnwindSafe for Integer
Blanket Implementations
Mutably borrows from an owned value. Read more