pub struct NetworkSimulator { /* private fields */ }Expand description
Network simulator for testing
Implementations§
Source§impl NetworkSimulator
impl NetworkSimulator
Sourcepub fn new(config: SimulatorConfig) -> Self
pub fn new(config: SimulatorConfig) -> Self
Create a new network simulator
Sourcepub fn from_condition(condition: NetworkCondition) -> Self
pub fn from_condition(condition: NetworkCondition) -> Self
Create simulator from a network condition
Sourcepub async fn start(&self) -> Result<(), SimulatorError>
pub async fn start(&self) -> Result<(), SimulatorError>
Start the simulator
Sourcepub async fn stop(&self) -> Result<(), SimulatorError>
pub async fn stop(&self) -> Result<(), SimulatorError>
Stop the simulator
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if simulator is running
Sourcepub async fn delay_packet(
&self,
packet_size: usize,
) -> Result<bool, SimulatorError>
pub async fn delay_packet( &self, packet_size: usize, ) -> Result<bool, SimulatorError>
Simulate network delay for a packet
Sourcepub fn create_partition(&self, group1: Vec<String>, group2: Vec<String>)
pub fn create_partition(&self, group1: Vec<String>, group2: Vec<String>)
Create a network partition between two groups
Sourcepub fn clear_partitions(&self)
pub fn clear_partitions(&self)
Remove all partitions
Sourcepub fn is_partitioned(&self, peer1: &str, peer2: &str) -> bool
pub fn is_partitioned(&self, peer1: &str, peer2: &str) -> bool
Check if two peers are partitioned
Sourcepub fn stats(&self) -> SimulatorStats
pub fn stats(&self) -> SimulatorStats
Get current statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics
Sourcepub fn config(&self) -> &SimulatorConfig
pub fn config(&self) -> &SimulatorConfig
Get configuration
Sourcepub fn update_config(
&mut self,
config: SimulatorConfig,
) -> Result<(), SimulatorError>
pub fn update_config( &mut self, config: SimulatorConfig, ) -> Result<(), SimulatorError>
Update configuration (only works when stopped)
Auto Trait Implementations§
impl Freeze for NetworkSimulator
impl !RefUnwindSafe for NetworkSimulator
impl Send for NetworkSimulator
impl Sync for NetworkSimulator
impl Unpin for NetworkSimulator
impl !UnwindSafe for NetworkSimulator
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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