seqnum 0.1.0

Serial number arithmetic (wrapping sequenec numbers) for rust
Documentation
  • Coverage
  • 0%
    0 out of 18 items documented0 out of 8 items with examples
  • Size
  • Source code size: 7.75 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • sweet-security/seqnum
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tomerfiliba

Serial Number Arithmetics

This simple (zero deps) crate provides SequenceInt, a wrapper around u8/u16/u32/u64 that implements serial number arithmetic (as defined by RFC 1982) in rust.

This is useful for sequence numbers, like in TCP, where one would want to be able to order packets even though their sequence numbers wrap around. Taking u16 for instance, 0xfffe_u16 < 0xffff_u16 < 0_u16.

use serial_int::SeqU16;

// thiss falls below the mid-point between the two numbers, making 1000 smaller
assert!(SeqU16::from(1000) < SeqU16::from(33000));

// this crosses the mid-point between the two numbers, making 1000 greater
assert!(SeqU16::from(1000) > SeqU16::from(34000));