pub struct WeakSimWorld { /* private fields */ }Expand description
A weak reference to a simulation world.
This provides handle-based access to the simulation without holding a strong reference that would prevent cleanup.
Implementations§
Source§impl WeakSimWorld
impl WeakSimWorld
Sourcepub fn upgrade(&self) -> SimulationResult<SimWorld>
pub fn upgrade(&self) -> SimulationResult<SimWorld>
Attempts to upgrade this weak reference to a strong reference.
Sourcepub fn current_time(&self) -> SimulationResult<Duration>
pub fn current_time(&self) -> SimulationResult<Duration>
Returns the current simulation time.
Sourcepub fn now(&self) -> SimulationResult<Duration>
pub fn now(&self) -> SimulationResult<Duration>
Returns the exact simulation time (equivalent to FDB’s now()).
Sourcepub fn timer(&self) -> SimulationResult<Duration>
pub fn timer(&self) -> SimulationResult<Duration>
Returns the drifted timer time (equivalent to FDB’s timer()).
Sourcepub fn schedule_event(
&self,
event: Event,
delay: Duration,
) -> SimulationResult<()>
pub fn schedule_event( &self, event: Event, delay: Duration, ) -> SimulationResult<()>
Schedules an event to execute after the specified delay.
Sourcepub fn schedule_event_at(
&self,
event: Event,
time: Duration,
) -> SimulationResult<()>
pub fn schedule_event_at( &self, event: Event, time: Duration, ) -> SimulationResult<()>
Schedules an event to execute at the specified absolute time.
Sourcepub fn read_from_connection(
&self,
connection_id: ConnectionId,
buf: &mut [u8],
) -> SimulationResult<usize>
pub fn read_from_connection( &self, connection_id: ConnectionId, buf: &mut [u8], ) -> SimulationResult<usize>
Read data from connection’s receive buffer.
Sourcepub fn write_to_connection(
&self,
connection_id: ConnectionId,
data: &[u8],
) -> SimulationResult<()>
pub fn write_to_connection( &self, connection_id: ConnectionId, data: &[u8], ) -> SimulationResult<()>
Write data to connection’s receive buffer.
Sourcepub fn buffer_send(
&self,
connection_id: ConnectionId,
data: Vec<u8>,
) -> SimulationResult<()>
pub fn buffer_send( &self, connection_id: ConnectionId, data: Vec<u8>, ) -> SimulationResult<()>
Buffer data for ordered sending on a connection.
Sourcepub fn network_provider(&self) -> SimulationResult<SimNetworkProvider>
pub fn network_provider(&self) -> SimulationResult<SimNetworkProvider>
Get a network provider for the simulation.
Sourcepub fn time_provider(&self) -> SimulationResult<SimTimeProvider>
pub fn time_provider(&self) -> SimulationResult<SimTimeProvider>
Get a time provider for the simulation.
Sourcepub fn sleep(&self, duration: Duration) -> SimulationResult<SleepFuture>
pub fn sleep(&self, duration: Duration) -> SimulationResult<SleepFuture>
Sleep for the specified duration in simulation time.
Sourcepub fn with_network_config<F, R>(&self, f: F) -> SimulationResult<R>where
F: FnOnce(&NetworkConfiguration) -> R,
pub fn with_network_config<F, R>(&self, f: F) -> SimulationResult<R>where
F: FnOnce(&NetworkConfiguration) -> R,
Access network configuration for latency calculations.