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.
Trait Implementations§
source§impl<'a> DerDecodable<'a> for Integer<'a>
impl<'a> DerDecodable<'a> for Integer<'a>
source§fn decode_at(raw: &'a [u8], header_start: usize) -> Result<Self, Asn1DerError>
fn decode_at(raw: &'a [u8], header_start: usize) -> Result<Self, Asn1DerError>
Decodes an object as
Self
source§fn decode_from_source<A: Source, B: Sink + Into<&'a [u8]>>(
source: &mut A,
sink: B
) -> Result<Self, Asn1DerError>
fn decode_from_source<A: Source, B: Sink + Into<&'a [u8]>>( source: &mut A, sink: B ) -> Result<Self, Asn1DerError>
Reads an object from
source
by parsing the length field and copying the necessary bytes
into sink
and decoding it from sink
source§impl<'a> DerEncodable for Integer<'a>
impl<'a> DerEncodable for Integer<'a>
source§impl<'a> DerTypeView<'a> for Integer<'a>
impl<'a> DerTypeView<'a> for Integer<'a>
impl<'a> Copy for Integer<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Integer<'a>
impl<'a> Send for Integer<'a>
impl<'a> Sync for Integer<'a>
impl<'a> Unpin for Integer<'a>
impl<'a> UnwindSafe for Integer<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more