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]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<T: Clone> Clone for SerialNumber<T>
[src]

[src]

Returns a copy of the value. Read more

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]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Debug> Debug for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: Display> Display for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Binary> Binary for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: Octal> Octal for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: LowerHex> LowerHex for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: UpperHex> UpperHex for SerialNumber<T>
[src]

[src]

Formats the value using the given formatter.

impl From<u8> for SerialNumber<u8>
[src]

[src]

Convert from this integer type into a SerialNumber.

Examples

assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));

impl Add for SerialNumber<u8>
[src]

The resulting type after applying the + operator.

[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]

The resulting type after applying the + operator.

[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]

[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]

[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]

[src]

Test if self and other of this integer type are equal.

Examples

assert_eq!(SerialNumber(42u8), 42u8);

1.0.0
[src]

This method tests for !=.

impl PartialOrd for SerialNumber<u8>
[src]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

Convert from this integer type into a SerialNumber.

Examples

assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));

impl Add for SerialNumber<u16>
[src]

The resulting type after applying the + operator.

[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]

The resulting type after applying the + operator.

[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]

[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]

[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]

[src]

Test if self and other of this integer type are equal.

Examples

assert_eq!(SerialNumber(42u8), 42u8);

1.0.0
[src]

This method tests for !=.

impl PartialOrd for SerialNumber<u16>
[src]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

Convert from this integer type into a SerialNumber.

Examples

assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));

impl Add for SerialNumber<u32>
[src]

The resulting type after applying the + operator.

[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]

The resulting type after applying the + operator.

[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]

[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]

[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]

[src]

Test if self and other of this integer type are equal.

Examples

assert_eq!(SerialNumber(42u8), 42u8);

1.0.0
[src]

This method tests for !=.

impl PartialOrd for SerialNumber<u32>
[src]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[src]

Convert from this integer type into a SerialNumber.

Examples

assert_eq!(SerialNumber::from(255u8), SerialNumber(255u8));

impl Add for SerialNumber<u64>
[src]

The resulting type after applying the + operator.

[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]

The resulting type after applying the + operator.

[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]

[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]

[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]

[src]

Test if self and other of this integer type are equal.

Examples

assert_eq!(SerialNumber(42u8), 42u8);

1.0.0
[src]

This method tests for !=.

impl PartialOrd for SerialNumber<u64>
[src]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

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]

[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));

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more