Struct sna::SerialNumber
[−]
[src]
pub struct SerialNumber<T>(pub T);
Provides an implementation of a Serial Number as defined by RFC 1982.
There are only two operations:
* +
will apply addition of a positive integer modulo the largest
representable number of this type (e.g. it will wrap when
overflowing).
* Partial equality operators are defined but may lead to surprising
results, so make sure you've read
chapter 3.2 of RFC 1982.
Examples
use sna::SerialNumber; let zero = SerialNumber(0u8); let one = SerialNumber(1u8); assert_eq!(0u8, one + 255u8); assert!(zero > 255u8);
Trait Implementations
impl<T: PartialEq> PartialEq for SerialNumber<T>
[src]
fn eq(&self, __arg_0: &SerialNumber<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &SerialNumber<T>) -> bool
[src]
This method tests for !=
.
impl<T: Clone> Clone for SerialNumber<T>
[src]
fn clone(&self) -> SerialNumber<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy> Copy for SerialNumber<T>
[src]
impl<T: Hash> Hash for SerialNumber<T>
[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
[src]
Feeds this value into the given [Hasher
]. Read more
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<T: Debug> Debug for SerialNumber<T>
[src]
impl<T: Display> Display for SerialNumber<T>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Binary> Binary for SerialNumber<T>
[src]
impl<T: Octal> Octal for SerialNumber<T>
[src]
impl<T: LowerHex> LowerHex for SerialNumber<T>
[src]
impl<T: UpperHex> UpperHex for SerialNumber<T>
[src]
impl From<u8> for SerialNumber<u8>
[src]
fn from(number: u8) -> Self
[src]
Convert from this integer type into a SerialNumber
.
Examples
assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));
impl Add for SerialNumber<u8>
[src]
type Output = SerialNumber<u8>
The resulting type after applying the +
operator.
fn add(self, other: SerialNumber<u8>) -> SerialNumber<u8>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + SerialNumber(4), 2u8);
impl Add<u8> for SerialNumber<u8>
[src]
type Output = SerialNumber<u8>
The resulting type after applying the +
operator.
fn add(self, other: u8) -> SerialNumber<u8>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + 4, 2u8);
impl AddAssign for SerialNumber<u8>
[src]
fn add_assign(&mut self, other: SerialNumber<u8>)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += SerialNumber(3u8); assert_eq!(SerialNumber(2), a);
impl AddAssign<u8> for SerialNumber<u8>
[src]
fn add_assign(&mut self, other: u8)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += 3u8; assert_eq!(SerialNumber(2), a);
impl PartialEq<u8> for SerialNumber<u8>
[src]
fn eq(&self, other: &u8) -> bool
[src]
Test if self
and other
of this integer type are
equal.
Examples
assert_eq!(SerialNumber(42u8), 42u8);
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for SerialNumber<u8>
[src]
fn partial_cmp(&self, other: &SerialNumber<u8>) -> Option<Ordering>
[src]
Return an ordering between self
and other
.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); let u8_max = SerialNumber(255u8); assert_eq!(zero.partial_cmp(&zero), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&u8_max), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialOrd<u8> for SerialNumber<u8>
[src]
fn partial_cmp(&self, other: &u8) -> Option<Ordering>
[src]
Return an ordering between self
and other
of this
integer type.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); assert_eq!(zero.partial_cmp(&0u8), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&255u8), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<u16> for SerialNumber<u16>
[src]
fn from(number: u16) -> Self
[src]
Convert from this integer type into a SerialNumber
.
Examples
assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));
impl Add for SerialNumber<u16>
[src]
type Output = SerialNumber<u16>
The resulting type after applying the +
operator.
fn add(self, other: SerialNumber<u16>) -> SerialNumber<u16>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + SerialNumber(4), 2u8);
impl Add<u16> for SerialNumber<u16>
[src]
type Output = SerialNumber<u16>
The resulting type after applying the +
operator.
fn add(self, other: u16) -> SerialNumber<u16>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + 4, 2u8);
impl AddAssign for SerialNumber<u16>
[src]
fn add_assign(&mut self, other: SerialNumber<u16>)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += SerialNumber(3u8); assert_eq!(SerialNumber(2), a);
impl AddAssign<u16> for SerialNumber<u16>
[src]
fn add_assign(&mut self, other: u16)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += 3u8; assert_eq!(SerialNumber(2), a);
impl PartialEq<u16> for SerialNumber<u16>
[src]
fn eq(&self, other: &u16) -> bool
[src]
Test if self
and other
of this integer type are
equal.
Examples
assert_eq!(SerialNumber(42u8), 42u8);
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for SerialNumber<u16>
[src]
fn partial_cmp(&self, other: &SerialNumber<u16>) -> Option<Ordering>
[src]
Return an ordering between self
and other
.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); let u8_max = SerialNumber(255u8); assert_eq!(zero.partial_cmp(&zero), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&u8_max), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialOrd<u16> for SerialNumber<u16>
[src]
fn partial_cmp(&self, other: &u16) -> Option<Ordering>
[src]
Return an ordering between self
and other
of this
integer type.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); assert_eq!(zero.partial_cmp(&0u8), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&255u8), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<u32> for SerialNumber<u32>
[src]
fn from(number: u32) -> Self
[src]
Convert from this integer type into a SerialNumber
.
Examples
assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));
impl Add for SerialNumber<u32>
[src]
type Output = SerialNumber<u32>
The resulting type after applying the +
operator.
fn add(self, other: SerialNumber<u32>) -> SerialNumber<u32>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + SerialNumber(4), 2u8);
impl Add<u32> for SerialNumber<u32>
[src]
type Output = SerialNumber<u32>
The resulting type after applying the +
operator.
fn add(self, other: u32) -> SerialNumber<u32>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + 4, 2u8);
impl AddAssign for SerialNumber<u32>
[src]
fn add_assign(&mut self, other: SerialNumber<u32>)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += SerialNumber(3u8); assert_eq!(SerialNumber(2), a);
impl AddAssign<u32> for SerialNumber<u32>
[src]
fn add_assign(&mut self, other: u32)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += 3u8; assert_eq!(SerialNumber(2), a);
impl PartialEq<u32> for SerialNumber<u32>
[src]
fn eq(&self, other: &u32) -> bool
[src]
Test if self
and other
of this integer type are
equal.
Examples
assert_eq!(SerialNumber(42u8), 42u8);
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for SerialNumber<u32>
[src]
fn partial_cmp(&self, other: &SerialNumber<u32>) -> Option<Ordering>
[src]
Return an ordering between self
and other
.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); let u8_max = SerialNumber(255u8); assert_eq!(zero.partial_cmp(&zero), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&u8_max), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialOrd<u32> for SerialNumber<u32>
[src]
fn partial_cmp(&self, other: &u32) -> Option<Ordering>
[src]
Return an ordering between self
and other
of this
integer type.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); assert_eq!(zero.partial_cmp(&0u8), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&255u8), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl From<u64> for SerialNumber<u64>
[src]
fn from(number: u64) -> Self
[src]
Convert from this integer type into a SerialNumber
.
Examples
assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));
impl Add for SerialNumber<u64>
[src]
type Output = SerialNumber<u64>
The resulting type after applying the +
operator.
fn add(self, other: SerialNumber<u64>) -> SerialNumber<u64>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + SerialNumber(4), 2u8);
impl Add<u64> for SerialNumber<u64>
[src]
type Output = SerialNumber<u64>
The resulting type after applying the +
operator.
fn add(self, other: u64) -> SerialNumber<u64>
[src]
Apply addition of a positive integer modulo the largest possible representable number of this type (e.g. it will wrap when overflowing).
Examples
assert_eq!(SerialNumber(254u8) + 4, 2u8);
impl AddAssign for SerialNumber<u64>
[src]
fn add_assign(&mut self, other: SerialNumber<u64>)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += SerialNumber(3u8); assert_eq!(SerialNumber(2), a);
impl AddAssign<u64> for SerialNumber<u64>
[src]
fn add_assign(&mut self, other: u64)
[src]
Performs the +=
operation modulo the largest possible
representable number of this type (e.g. it will wrap
when overflowing).
Examples
let mut a = SerialNumber(255u8); a += 3u8; assert_eq!(SerialNumber(2), a);
impl PartialEq<u64> for SerialNumber<u64>
[src]
fn eq(&self, other: &u64) -> bool
[src]
Test if self
and other
of this integer type are
equal.
Examples
assert_eq!(SerialNumber(42u8), 42u8);
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for SerialNumber<u64>
[src]
fn partial_cmp(&self, other: &SerialNumber<u64>) -> Option<Ordering>
[src]
Return an ordering between self
and other
.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); let u8_max = SerialNumber(255u8); assert_eq!(zero.partial_cmp(&zero), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&u8_max), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialOrd<u64> for SerialNumber<u64>
[src]
fn partial_cmp(&self, other: &u64) -> Option<Ordering>
[src]
Return an ordering between self
and other
of this
integer type.
Examples
use std::cmp::Ordering; let zero = SerialNumber(0u8); assert_eq!(zero.partial_cmp(&0u8), Some(Ordering::Equal)); assert_eq!(zero.partial_cmp(&255u8), Some(Ordering::Greater));
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more