pub struct SpawnContext<'a, D = ()> { /* private fields */ }
Expand description
Context provided when spawning a new simulation node.
Contains all the necessary information and resources for initializing a node, including its index, the shared setup data, and a metrics registry.
Implementations§
Source§impl<'a, D: SetupData> SpawnContext<'a, D>
impl<'a, D: SetupData> SpawnContext<'a, D>
Sourcepub fn node_index(&self) -> u32
pub fn node_index(&self) -> u32
Returns the index of this node in the simulation.
Sourcepub fn setup_data(&self) -> &D
pub fn setup_data(&self) -> &D
Returns a reference to the setup data for this simulation.
Sourcepub fn metrics_registry(&mut self) -> &mut Registry
pub fn metrics_registry(&mut self) -> &mut Registry
Returns a mutable reference to a metrics registry.
Use this to register custom metrics for the node being spawned.
Sourcepub fn secret_key(&self) -> SecretKey
pub fn secret_key(&self) -> SecretKey
Returns the secret key for this node.
Sourcepub async fn bind_endpoint(&self) -> Result<Endpoint>
pub async fn bind_endpoint(&self) -> Result<Endpoint>
Creates and binds a new endpoint with this node’s secret key.
§Errors
Returns an error if the endpoint fails to bind to a local address.
Auto Trait Implementations§
impl<'a, D> Freeze for SpawnContext<'a, D>
impl<'a, D = ()> !RefUnwindSafe for SpawnContext<'a, D>
impl<'a, D> Send for SpawnContext<'a, D>where
D: Sync,
impl<'a, D> Sync for SpawnContext<'a, D>where
D: Sync,
impl<'a, D> Unpin for SpawnContext<'a, D>
impl<'a, D = ()> !UnwindSafe for SpawnContext<'a, D>
Blanket Implementations§
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