seqnum

Crates.ioseqnum
lib.rsseqnum
version0.1.0
created_at2025-10-08 11:57:23.827456+00
updated_at2025-10-08 11:57:23.827456+00
descriptionSerial number arithmetic (wrapping sequenec numbers) for rust
homepage
repositoryhttps://github.com/sweet-security/seqnum
max_upload_size
id1873931
size8,219
Tomer Filiba (tomerfiliba)

documentation

README

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));
Commit count: 0

cargo fmt