Skip to main content

SerialPrimitive

Trait SerialPrimitive 

Source
pub trait SerialPrimitive: Copy + Ord {
    const HALF: Self;

    // Required methods
    fn wrapping_add(self, rhs: Self) -> Self;
    fn wrapping_sub(self, rhs: Self) -> Self;
}
Expand description

An unsigned integer type that can serve as the underlying storage for a serial number.

Already implemented for u8/u16/u32/u64/u128/usize; usually no manual implementation is needed.

Required Associated Constants§

Source

const HALF: Self

The “half cycle” size of the wraparound space, i.e. 2^(BITS-1).

Per RFC 1982 the largest valid addend is HALF - 1; HALF itself already lies in the “undefined” region. It is also the dividing point that distinguishes the “front half / back half” of a cycle during comparison.

Required Methods§

Source

fn wrapping_add(self, rhs: Self) -> Self

Wraparound addition.

Source

fn wrapping_sub(self, rhs: Self) -> Self

Wraparound subtraction.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl SerialPrimitive for u8

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Source§

impl SerialPrimitive for u16

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Source§

impl SerialPrimitive for u32

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Source§

impl SerialPrimitive for u64

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Source§

impl SerialPrimitive for u128

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Source§

impl SerialPrimitive for usize

Source§

const HALF: Self

Source§

fn wrapping_add(self, rhs: Self) -> Self

Source§

fn wrapping_sub(self, rhs: Self) -> Self

Implementors§