[][src]Struct zenoh_protocol::proto::SeqNum

pub struct SeqNum { /* fields omitted */ }

Sequence Number

Zenoh sequence numbers have a negotiable resolution. Each session can ideally negotiate its resolution and use it across all conduits.

The SeqNum encapsulates the sequence numbers along with a the comparison operators that check whether two sequence numbers are less, equeal or greater of each other.

Implementations

impl SeqNum[src]

pub fn new(value: ZInt, resolution: ZInt) -> SeqNum[src]

Create a new sequence number with a given resolution.

Arguments

  • value - The sequence number.

  • resolution - The resolution (modulo) to be used for the sequence number. As a consequence of wire zenoh's representation of sequence numbers it is recommended that the resolution is a power of 2 with exponent multiple of 7. Suggested values are: - 256 (i.e., 2^7) - 16_386 (i.e., 2^14) - 2_097_152 (i.e., 2^21)

This funtion will panic if value is out of bound w.r.t. resolution. That is if value is greater or equal than resolution.

pub fn resolution(&self) -> ZInt[src]

pub fn semi_int(&self) -> ZInt[src]

pub fn get(&self) -> ZInt[src]

pub fn set(&mut self, value: ZInt) -> ZResult<()>[src]

pub fn increment(&mut self)[src]

pub fn precedes(&self, value: ZInt) -> ZResult<bool>[src]

Checks to see if two sequence number are in a precedence relationship, while taking into account roll backs.

Two case are considered:

Case 1: sna < snb

In this case sna precedes snb iff (snb - sna) <= semi_int where semi_int is defined as half the sequence number resolution. In other terms, sna precedes snb iff there are less than half the length for the interval that separates them.

Case 2: sna > snb

In this case sna precedes snb iff (sna - snb) > semi_int.

Arguments

  • value - The sequence number which should be checked for precedence relation.

pub fn gap(&self, value: ZInt) -> ZResult<ZInt>[src]

Computes the modulo gap between two sequence numbers.

Two case are considered:

Case 1: sna < snb

In this case the gap is computed as snb - sna.

Case 2: sna > snb

In this case the gap is computed as resolution - (sna - snb).

Arguments

  • value - The sequence number which should be checked for gap computation.

Trait Implementations

impl Clone for SeqNum[src]

impl Copy for SeqNum[src]

impl Debug for SeqNum[src]

Auto Trait Implementations

impl RefUnwindSafe for SeqNum

impl Send for SeqNum

impl Sync for SeqNum

impl Unpin for SeqNum

impl UnwindSafe for SeqNum

Blanket Implementations

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,