Trait DynNode

Source
pub trait DynNode:
    Send
    + Any
    + 'static {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;

    // Provided methods
    fn shutdown(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>> { ... }
    fn endpoint(&self) -> Option<&Endpoint> { ... }
}
Expand description

Trait for dynamically-typed simulation nodes.

This trait enables type erasure for nodes while preserving essential functionality like shutdown, endpoint access, and type casting.

Required Methods§

Source

fn as_any(&self) -> &dyn Any

Returns a reference to this node as Any for downcasting.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to this node as Any for downcasting.

Provided Methods§

Source

fn shutdown(&mut self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>

Shuts down this node, performing any necessary cleanup.

The default implementation does nothing and returns success.

§Errors

Returns an error if shutdown fails.

Source

fn endpoint(&self) -> Option<&Endpoint>

Returns a reference to this node’s endpoint, if any.

The default implementation returns None.

Implementors§

Source§

impl<T: Node + Sized> DynNode for T