[−][src]Struct bcder::int::Unsigned
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.
Methods
impl Unsigned
[src]
pub fn take_from<S: Source>(cons: &mut Constructed<S>) -> Result<Self, S::Err>
[src]
pub fn from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<Self, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<Self, S::Err>
pub fn u8_from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<u8, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<u8, S::Err>
pub fn u16_from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<u16, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<u16, S::Err>
pub fn u32_from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<u32, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<u32, S::Err>
pub fn u64_from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<u64, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<u64, S::Err>
pub fn u128_from_primitive<S: Source>(
prim: &mut Primitive<S>
) -> Result<u128, S::Err>
[src]
prim: &mut Primitive<S>
) -> Result<u128, S::Err>
pub fn into_bytes(self) -> Bytes
[src]
Trades the integer into a bytes value with the raw content octets.
pub fn as_slice(&self) -> &[u8]
[src]
Returns a bytes slice with the raw content.
pub fn is_zero(&self) -> bool
[src]
Returns whether the number is zero.
Trait Implementations
impl<'a> PrimitiveContent for &'a Unsigned
[src]
const TAG: Tag
[src]
fn encoded_len(&self, mode: Mode) -> usize
[src]
fn write_encoded<W: Write>(
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
[src]
&self,
mode: Mode,
target: &mut W
) -> Result<(), Error>
fn to_encoded_bytes(&self, mode: Mode) -> Bytes
[src]
Encodes the value to bytes (useful when you need to sign a structure)
fn encode(self) -> Primitive<Self>
[src]
Returns a value encoder for this content using the natural tag. Read more
fn encode_as(self, tag: Tag) -> Primitive<Self>
[src]
Returns a value encoder for this content using the given tag. Read more
fn encode_ref(&self) -> Primitive<&Self>
[src]
Returns a value encoder for a reference using the natural tag.
fn encode_ref_as(&self, tag: Tag) -> Primitive<&Self>
[src]
Returns a value encoder for a reference using the given tag.
impl Eq for Unsigned
[src]
impl Ord for Unsigned
[src]
fn cmp(&self, other: &Unsigned) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl PartialEq<Unsigned> for Integer
[src]
fn eq(&self, other: &Unsigned) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialEq<Unsigned> for Unsigned
[src]
impl Clone for Unsigned
[src]
fn clone(&self) -> Unsigned
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialOrd<Unsigned> for Unsigned
[src]
fn partial_cmp(&self, other: &Unsigned) -> Option<Ordering>
[src]
fn lt(&self, other: &Unsigned) -> bool
[src]
fn le(&self, other: &Unsigned) -> bool
[src]
fn gt(&self, other: &Unsigned) -> bool
[src]
fn ge(&self, other: &Unsigned) -> bool
[src]
impl AsRef<Integer> for Unsigned
[src]
impl AsRef<Bytes> for Unsigned
[src]
impl AsRef<[u8]> for Unsigned
[src]
impl From<u8> for Unsigned
[src]
impl From<u16> for Unsigned
[src]
impl From<u32> for Unsigned
[src]
impl From<u64> for Unsigned
[src]
impl From<u128> for Unsigned
[src]
impl Debug for Unsigned
[src]
impl Hash for Unsigned
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a> TryFrom<&'a Unsigned> for i8
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<i8, Self::Error>
[src]
impl TryFrom<Unsigned> for i8
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<i8, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for i16
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<i16, Self::Error>
[src]
impl TryFrom<Unsigned> for i16
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<i16, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for i32
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<i32, Self::Error>
[src]
impl TryFrom<Unsigned> for i32
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<i32, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for i64
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<i64, Self::Error>
[src]
impl TryFrom<Unsigned> for i64
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<i64, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for i128
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<i128, Self::Error>
[src]
impl TryFrom<Unsigned> for i128
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<i128, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for u8
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<u8, Self::Error>
[src]
impl TryFrom<Unsigned> for u8
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<u8, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for u16
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<u16, Self::Error>
[src]
impl TryFrom<Unsigned> for u16
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<u16, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for u32
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<u32, Self::Error>
[src]
impl TryFrom<Unsigned> for u32
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<u32, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for u64
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<u64, Self::Error>
[src]
impl TryFrom<Unsigned> for u64
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: Unsigned) -> Result<u64, Self::Error>
[src]
impl<'a> TryFrom<&'a Unsigned> for u128
[src]
type Error = OverflowError
The type returned in the event of a conversion error.
fn try_from(val: &'a Unsigned) -> Result<u128, Self::Error>
[src]
impl TryFrom<Unsigned> for u128
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,