Struct Model

Source
pub struct Model<V>
where V: Vector + Debug,
{ /* private fields */ }
Expand description

A Vivaldi latency model generic over N dimensional vectors.

A single Model should be instantiated for each distinct network of nodes the caller participates in.

Messages exchanged between nodes in the network should include the current model coordinate, and the model should be updated with the measured round-trip time by calling observe.

Implementations§

Source§

impl<V> Model<V>
where V: Vector + Debug,

Source

pub fn new() -> Model<V>

New initialises a new Vivaldi model.

The model is generic over any implementation of the Vector trait, which should be specified when calling this method:

use vivaldi::{Model, vector::Dimension3};

let model = Model::<Dimension3>::new();
Source

pub fn observe(&mut self, coord: &Coordinate<V>, rtt: Duration)

Observe updates the positional coordinate of the local node.

This method should be called with the coordinate of the remote node and the network round-trip time measured by the caller:


// The remote sends it's current coordinate.
//
// Lets pretend we got this from an RPC response:
let coordinate_from_remote = remote_model.get_coordinate();

// The local application issues a request and measures the response time
let rtt = std::time::Duration::new(0, 42_000);

// And then updates the model with the remote coordinate and rtt
model.observe(&coordinate_from_remote, rtt);
Source

pub fn get_coordinate(&self) -> &Coordinate<V>

Returns the current positional coordinate of the local node.

Trait Implementations§

Source§

impl<V> Debug for Model<V>
where V: Vector + Debug + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<V> Freeze for Model<V>
where V: Freeze,

§

impl<V> RefUnwindSafe for Model<V>
where V: RefUnwindSafe,

§

impl<V> Send for Model<V>
where V: Send,

§

impl<V> Sync for Model<V>
where V: Sync,

§

impl<V> Unpin for Model<V>
where V: Unpin,

§

impl<V> UnwindSafe for Model<V>
where V: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V