pub struct Seq(/* private fields */);
Expand description
16 bit RTP sequence number value, as obtained from the sequence_number()
method of RtpReader.
use rtp_rs::*;
let seq = Seq::from(123);
This type’s behavior attempts to honour the expected wrap-around of sequence number values
from 0xffff
back to 0x0000
.
You can perform logic over sequences of RTP packets using this type and other helpers from this crate,
let start = Seq::from(0xfffe);
let end = Seq::from(0x0002);
// produces the Seq values 0xfffe, 0xffff, 0x0000, 0x0001:
for seq in (start..end).seq_iter() {
// ...inspect some RTP packet you've stored against this sequence number...
}
§Unsoundness
Note this type has implementations of Ord
and PartialOrd
, but those implementations
violate the requirement for transitivity which both traits document.
let a = Seq::from(0);
let b = a + 0x7fff;
let c = b + 0x7fff;
assert!(a < b);
assert!(b < c);
assert!(a < c); // Assertion fails, in violation of Ord/PartialOrd requirements
A future release will potentially deprecate Ord
/ PartialOrd
implementations for Seq
, and
hopefully provide a mechanism for sequence number processing which is sound.
Implementations§
Trait Implementations§
Source§impl Ord for Seq
impl Ord for Seq
Source§impl PartialOrd for Seq
impl PartialOrd for Seq
Source§impl Sub for Seq
Implements wrapped subtraction such that for instance Seq(0x0000) - Seq(0xffff)
results in
1
(rather than -65535
).
impl Sub for Seq
Implements wrapped subtraction such that for instance Seq(0x0000) - Seq(0xffff)
results in
1
(rather than -65535
).
This is for symmetry with addition, where for example Seq(0xffff) + 1
gives Seq(0x0000)