NetworkSimulator

Struct NetworkSimulator 

Source
pub struct NetworkSimulator<D> {
    in_flight: VecDeque<AntiEntropyMessage<D>>,
    lost: Vec<AntiEntropyMessage<D>>,
    config: NetworkConfig,
    rng_state: u64,
}
Expand description

A network simulator for testing anti-entropy under various conditions

Fields§

§in_flight: VecDeque<AntiEntropyMessage<D>>

Messages in flight

§lost: Vec<AntiEntropyMessage<D>>

Messages that were “lost”

§config: NetworkConfig

Configuration

§rng_state: u64

Random seed for deterministic testing

Implementations§

Source§

impl<D: Clone> NetworkSimulator<D>

Source

pub fn new(config: NetworkConfig) -> Self

Source

fn next_random(&mut self) -> f64

Simple LCG random number generator

Source

pub fn send(&mut self, msg: AntiEntropyMessage<D>)

Send a message through the network

Source

pub fn receive(&mut self) -> Option<AntiEntropyMessage<D>>

Receive the next message (if any)

Source

pub fn retransmit_lost(&mut self)

Re-send lost messages (simulates retransmission)

Source

pub fn is_empty(&self) -> bool

Check if network is empty

Source

pub fn in_flight_count(&self) -> usize

Number of messages in flight

Source

pub fn lost_count(&self) -> usize

Number of lost messages

Trait Implementations§

Source§

impl<D: Debug> Debug for NetworkSimulator<D>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for NetworkSimulator<D>

§

impl<D> RefUnwindSafe for NetworkSimulator<D>
where D: RefUnwindSafe,

§

impl<D> Send for NetworkSimulator<D>
where D: Send,

§

impl<D> Sync for NetworkSimulator<D>
where D: Sync,

§

impl<D> Unpin for NetworkSimulator<D>
where D: Unpin,

§

impl<D> UnwindSafe for NetworkSimulator<D>
where D: 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.
§

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

§

fn vzip(self) -> V