SvsNode

Struct SvsNode 

Source
pub struct SvsNode { /* private fields */ }
Expand description

State Vector Sync (SVS).

Each node maintains a state vector — a map from node-name key to the highest sequence number the local node has seen for that peer. When a peer’s sequence number in a received sync Interest is higher than the local entry, the gap is recorded as “missing data” that should be fetched.

Node names are stored as canonical string keys so the vector can be compared across the network without re-encoding Name objects on every merge.

Implementations§

Source§

impl SvsNode

Source

pub fn new(local_name: &Name) -> Self

Source

pub fn local_key(&self) -> &str

Source

pub async fn local_seq(&self) -> u64

Return the current sequence number for the local node.

Source

pub async fn advance(&self) -> u64

Increment the local sequence number by 1 and return the new value.

Source

pub async fn merge(&self, received: &[(String, u64)]) -> Vec<(String, u64, u64)>

Merge a received state vector into the local one.

For each entry, if the received sequence number is higher than the locally known value the local entry is updated. Returns a list of (node_key, gap_from, gap_to) tuples describing missing data that should be fetched.

Source

pub async fn snapshot(&self) -> Vec<StateVectorEntry>

Return a snapshot of the current state vector.

Source

pub async fn seq_for(&self, node_key: &str) -> u64

Return the sequence number known for node_key, or 0 if unknown.

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

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.