use sdtn::{BundleStatus, DtnNode};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let node = DtnNode::new()?;
println!("๐ฆ Inserting a new bundle...");
node.insert_bundle("Hello from SpaceArth DTN!".to_string())
.await?;
println!("๐ Listing all bundles...");
let bundles = node.list_bundles()?;
println!("Found {} bundles:", bundles.len());
for id in &bundles {
println!(" {}", id);
}
if let Some(first_id) = bundles.first() {
println!("๐ Showing details for bundle: {}", first_id);
let bundle = node.show_bundle(first_id)?;
println!(" Source: {}", bundle.primary.source);
println!(" Destination: {}", bundle.primary.destination);
println!(" Message: {}", String::from_utf8_lossy(&bundle.payload));
println!(" Expired: {}", bundle.is_expired());
}
println!("๐ Getting status summary...");
let status = node.get_bundle_status(None)?;
match status {
BundleStatus::Summary {
active,
expired,
total,
} => {
println!(" Active bundles: {}", active);
println!(" Expired bundles: {}", expired);
println!(" Total bundles: {}", total);
}
_ => unreachable!(),
}
println!("๐งน Cleaning up expired bundles...");
node.cleanup_expired()?;
println!("โ
Basic usage example completed!");
Ok(())
}