Struct rtp_rs::Seq[][src]

pub struct Seq(_);
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

impl Seq[src]

pub fn next(self) -> Seq[src]

Produce the sequence value which follows this one.

Sequence numbers wrap back to 0x0000 after reaching the value 0xffff

pub fn precedes(self, other: Seq) -> bool[src]

Returns true if this sequence number value is immediately before the given one

Trait Implementations

impl Add<u16> for Seq[src]

type Output = Seq

The resulting type after applying the + operator.

fn add(self, rhs: u16) -> Self::Output[src]

Performs the + operation. Read more

impl Clone for Seq[src]

fn clone(&self) -> Seq[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Seq[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl From<u16> for Seq[src]

fn from(v: u16) -> Self[src]

Performs the conversion.

impl Ord for Seq[src]

fn cmp(&self, other: &Self) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Seq> for Seq[src]

fn eq(&self, other: &Seq) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Seq) -> bool[src]

This method tests for !=.

impl PartialOrd<Seq> for Seq[src]

fn partial_cmp(&self, other: &Seq) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Sub<Seq> for Seq[src]

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)

type Output = i32

The resulting type after applying the - operator.

fn sub(self, rhs: Seq) -> Self::Output[src]

Performs the - operation. Read more

impl Copy for Seq[src]

impl Eq for Seq[src]

impl StructuralEq for Seq[src]

impl StructuralPartialEq for Seq[src]

Auto Trait Implementations

impl RefUnwindSafe for Seq

impl Send for Seq

impl Sync for Seq

impl Unpin for Seq

impl UnwindSafe for Seq

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.