Skip to main content

Crate serial_uint

Crate serial_uint 

Source
Expand description

Serial Number arithmetic following RFC 1982 semantics.

A serial number is a fixed-width unsigned integer whose operations “wrap around” (wraparound). Its biggest difference from an ordinary integer is comparison: in the wraparound space MAX is the predecessor of 0, so Serial(MAX) < Serial(0).

  • Add / subtract an offset: Serial + T / Serial - T, both wraparound operations.
  • Wraparound comparison: implements PartialOrd. When two serial numbers are exactly half a cycle apart, their ordering is undefined and partial_cmp returns None (this is why PartialOrd is used instead of Ord).

Generics support u8 / u16 / u32 / u64 / u128 / usize and other widths.

Structs§

Serial
A wraparound serial number.

Traits§

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