diff --git a/Cargo.lock b/Cargo.lock index 94a2e66..2a5cf04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1936,6 +1936,7 @@ dependencies = [ "irpc", "irpc-iroh", "n0-future", + "paste", "rand 0.8.5", "rcan", "serde", diff --git a/Cargo.toml b/Cargo.toml index 65c3b74..cca1d12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ rust-version = "1.81" anyhow = "1.0.95" derive_more = { version = "2.0.1", features = ["from"] } ed25519-dalek = "2.1.1" + irpc = "0.3.0" irpc-iroh = "0.3.0" iroh = "0.35" @@ -21,6 +22,7 @@ iroh-blobs = "0.35" iroh-gossip = { version = "0.35", default-features = false } iroh-metrics = "0.34" n0-future = "0.1.2" +paste = "1.0.14" rand = "0.8" rcan = { git = "https://github.com/n0-computer/rcan", branch = "main" } serde = { version = "1.0.217", features = ["derive"] } diff --git a/src/lib.rs b/src/lib.rs index 73d9115..d04c555 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,11 @@ mod client; +mod n0des; pub mod caps; pub mod protocol; pub use self::{ client::{Client, ClientBuilder}, + n0des::N0de, protocol::ALPN, }; diff --git a/src/n0des.rs b/src/n0des.rs new file mode 100644 index 0000000..8118c28 --- /dev/null +++ b/src/n0des.rs @@ -0,0 +1,14 @@ +use std::future::Future; + +use anyhow::Result; +use iroh::Endpoint; + +/// A trait for nodes that can be spawned and shut down +pub trait N0de: 'static + Send { + fn spawn(endpoint: Endpoint) -> impl Future> + Send + where + Self: Sized; + + /// Asynchronously shut down the node + fn shutdown(&mut self) -> impl Future> + Send; +}