pub struct Integer<'a> { /* private fields */ }
Expand description
An ASN.1-DER integer view
Implementations§
source§impl<'a> Integer<'a>
impl<'a> Integer<'a>
sourcepub fn new<S: Sink + Into<&'a [u8]>>(
be_value: &[u8],
is_negative: bool,
sink: S
) -> Result<Self, Asn1DerError>
pub fn new<S: Sink + Into<&'a [u8]>>(
be_value: &[u8],
is_negative: bool,
sink: S
) -> Result<Self, Asn1DerError>
Writes a new integer object with the big-endian encoded be_value
into sink
and returns a
type view over it
sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns if the number is negative or not
sourcepub fn get_numbytes(&self) -> &[u8] ⓘ
pub fn get_numbytes(&self) -> &[u8] ⓘ
Get the number bytes
Important: Any leading zero-byte that might indicate a positive number is stripped off.
This means that a return value of 0b1111_1111
can be either 255
or -1
depending on
whether the number is negative or not. Use is_negative
to determine the correct sign.
sourcepub fn copy_numbytes<T: AsMut<[u8]>>(&self, buf: T) -> Result<T, Asn1DerError>
pub fn copy_numbytes<T: AsMut<[u8]>>(&self, buf: T) -> Result<T, Asn1DerError>
Copies the num bytes into buf
if they can fit
Important: Any leading zero-byte that might indicate a positive number is stripped off.
This means that a return value of 0b1111_1111
can be either 255
or -1
depending on
whether the number is negative or not. Use is_negative
to determine the correct sign.