Enum quilkin::codec::qcmp::Protocol

source ·
pub enum Protocol {
    Ping {
        client_timestamp: UtcTimestamp,
        nonce: u8,
    },
    PingReply {
        client_timestamp: UtcTimestamp,
        nonce: u8,
        server_start_timestamp: UtcTimestamp,
        server_transmit_timestamp: UtcTimestamp,
    },
}
Expand description

The set of possible QCMP commands.

Variants§

§

Ping

Fields

§client_timestamp: UtcTimestamp

The timestamp from when the client sent the packet.

§nonce: u8

The client’s nonce.

The initation of a ping command to send to a Quilkin proxy to measure latency.

§

PingReply

Fields

§client_timestamp: UtcTimestamp

The timestamp from when the client sent the ping packet.

§nonce: u8

The client’s nonce.

§server_start_timestamp: UtcTimestamp

The timestamp from when the server received the ping packet.

§server_transmit_timestamp: UtcTimestamp

The timestamp from when the server sent the reply.

The reply from a Quilkin proxy from a Self::Ping command. Can be used with Protocol::round_trip_delay to measure latency between two machines.

Implementations§

source§

impl Protocol

source

pub fn ping() -> Self

Creates a Self::Ping with a random nonce, should be sent as soon as possible from creation to maintain accuracy.

source

pub fn ping_with_nonce(nonce: u8) -> Self

Creates a Self::Ping with a user-specified nonce, should be sent as soon as possible from creation to maintain accuracy.

source

pub fn ping_reply( nonce: u8, client_timestamp: UtcTimestamp, server_start_timestamp: UtcTimestamp ) -> Self

Creates a Self::PingReply from the client and server start timestamp. It’s recommended to transmit as as soon as possible from creation to keep the start and transmit times as accurate as possible.

source

pub fn encode<'buf>(&self, buffer: &'buf mut QcmpPacket) -> &'buf [u8]

Encodes the protocol command into a buffer of bytes for network transmission.

source

pub fn nonce(&self) -> u8

Returns the packet’s nonce.

source

pub fn round_trip_delay( &self, client_response_timestamp: UtcTimestamp ) -> Option<DurationNanos>

If the command is Protocol::PingReply, with client_response_timestamp measures the roundtrip delay between the client machine, and the Quilkin proxy, using the same algorithm as Network Time Protocol (NTP).

source

pub fn distance( &self, client_response_timestamp: UtcTimestamp ) -> Option<DistanceMeasure>

If the command is Protocol::PingReply, with client_response_timestamp returns the time between the client -> server, and the server -> client.

source

pub fn parse(input: &[u8]) -> Result<Option<Self>, Error>

Parses the provided input, and attempts to parse it as a Protocol packet.

Returns None if the magic number is not present, and thus is not a QCMP packet, and returning Err when it was detected as a QCMP packet, but there was an error in parsing the payload.

Trait Implementations§

source§

impl Clone for Protocol

source§

fn clone(&self) -> Protocol

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Protocol

source§

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

Formats the value using the given formatter. Read more
source§

impl Copy for Protocol

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more