pub struct SpawnContext<'a, C: Ctx = ()> { /* 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, C: Ctx> SpawnContext<'a, C>
impl<'a, C: Ctx> SpawnContext<'a, C>
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) -> &C::Setup
pub fn setup_data(&self) -> &C::Setup
Returns a reference to the setup data for this simulation.
pub fn config(&self) -> &C::Config
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, C> Freeze for SpawnContext<'a, C>
impl<'a, C = ()> !RefUnwindSafe for SpawnContext<'a, C>
impl<'a, C> Send for SpawnContext<'a, C>
impl<'a, C> Sync for SpawnContext<'a, C>
impl<'a, C> Unpin for SpawnContext<'a, C>
impl<'a, C = ()> !UnwindSafe for SpawnContext<'a, C>
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