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) -> Result<SimWorld, SimulationError>
pub fn upgrade(&self) -> Result<SimWorld, SimulationError>
Attempts to upgrade this weak reference to a strong reference.
§Errors
Returns an error if the operation is rejected by the simulator (for example, the simulation has not been started).
Sourcepub fn current_time(&self) -> Result<Duration, SimulationError>
pub fn current_time(&self) -> Result<Duration, SimulationError>
Sourcepub fn now(&self) -> Result<Duration, SimulationError>
pub fn now(&self) -> Result<Duration, SimulationError>
Returns the exact simulation time (equivalent to FDB’s now()).
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn timer(&self) -> Result<Duration, SimulationError>
pub fn timer(&self) -> Result<Duration, SimulationError>
Returns the drifted timer time (equivalent to FDB’s timer()).
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn schedule_event(
&self,
event: Event,
delay: Duration,
) -> Result<(), SimulationError>
pub fn schedule_event( &self, event: Event, delay: Duration, ) -> Result<(), SimulationError>
Schedules an event to execute after the specified delay.
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn schedule_event_at(
&self,
event: Event,
time: Duration,
) -> Result<(), SimulationError>
pub fn schedule_event_at( &self, event: Event, time: Duration, ) -> Result<(), SimulationError>
Schedules an event to execute at the specified absolute time.
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn read_from_connection(
&self,
connection_id: ConnectionId,
buf: &mut [u8],
) -> Result<usize, SimulationError>
pub fn read_from_connection( &self, connection_id: ConnectionId, buf: &mut [u8], ) -> Result<usize, SimulationError>
Read data from connection’s receive buffer.
§Errors
Returns an error if the simulation has been dropped or the underlying operation is rejected by the simulator.
Sourcepub fn write_to_connection(
&self,
connection_id: ConnectionId,
data: &[u8],
) -> Result<(), SimulationError>
pub fn write_to_connection( &self, connection_id: ConnectionId, data: &[u8], ) -> Result<(), SimulationError>
Write data to connection’s receive buffer.
§Errors
Returns an error if the simulation has been dropped or the underlying operation is rejected by the simulator.
Sourcepub fn buffer_send(
&self,
connection_id: ConnectionId,
data: Vec<u8>,
) -> Result<(), SimulationError>
pub fn buffer_send( &self, connection_id: ConnectionId, data: Vec<u8>, ) -> Result<(), SimulationError>
Buffer data for ordered sending on a connection.
§Errors
Returns an error if the simulation has been dropped or the underlying operation is rejected by the simulator.
Sourcepub fn network_provider(&self) -> Result<SimNetworkProvider, SimulationError>
pub fn network_provider(&self) -> Result<SimNetworkProvider, SimulationError>
Get a network provider for the simulation.
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn time_provider(&self) -> Result<SimTimeProvider, SimulationError>
pub fn time_provider(&self) -> Result<SimTimeProvider, SimulationError>
Get a time provider for the simulation.
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn sleep(&self, duration: Duration) -> Result<SleepFuture, SimulationError>
pub fn sleep(&self, duration: Duration) -> Result<SleepFuture, SimulationError>
Sleep for the specified duration in simulation time.
§Errors
Returns an error if the simulation has been dropped.
Sourcepub fn with_network_config<F, R>(&self, f: F) -> Result<R, SimulationError>where
F: FnOnce(&NetworkConfiguration) -> R,
pub fn with_network_config<F, R>(&self, f: F) -> Result<R, SimulationError>where
F: FnOnce(&NetworkConfiguration) -> R,
Access network configuration for latency calculations.
§Errors
Returns an error if the operation is rejected by the simulator (for example, the simulation has not been started).
Trait Implementations§
Source§impl Clone for WeakSimWorld
impl Clone for WeakSimWorld
Source§fn clone(&self) -> WeakSimWorld
fn clone(&self) -> WeakSimWorld
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more