mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 22:10:31 +08:00
This keeps the top level of the repo cleaner, e.g. <https://github.com/radicle-dev/heartwood> scrolls less and <https://app.radicle.xyz/nodes/rosa.radicle.xyz/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5/> might show more files at the top level. This way we also don't have to explicitly name all crates in `Cargo.toml`.
24 lines
532 B
Rust
24 lines
532 B
Rust
use std::time;
|
|
|
|
use radicle::node::{Event, Handle};
|
|
|
|
pub fn run<H>(node: H, count: usize, timeout: time::Duration) -> anyhow::Result<()>
|
|
where
|
|
H: Handle<Event = Result<Event, <H as Handle>::Error>>,
|
|
{
|
|
let events = node.subscribe(timeout)?;
|
|
for (i, event) in events.into_iter().enumerate() {
|
|
let event = event?;
|
|
let obj = serde_json::to_string(&event)?;
|
|
|
|
println!("{obj}");
|
|
|
|
// Only output up to `count` events.
|
|
if i + 1 >= count {
|
|
break;
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|