iroh_n0des/
n0des.rs

1use std::future::Future;
2
3use anyhow::Result;
4use iroh::Endpoint;
5use iroh_metrics::Registry;
6
7/// A trait for nodes that can be spawned and shut down
8pub trait N0de: 'static + Send + Sync {
9    fn spawn(
10        endpoint: Endpoint,
11        metrics: &mut Registry,
12    ) -> impl Future<Output = Result<Self>> + Send
13    where
14        Self: Sized;
15
16    /// Asynchronously shut down the node
17    fn shutdown(&mut self) -> impl Future<Output = Result<()>> + Send {
18        async move { Ok(()) }
19    }
20}