Expand description
Adaptation of iroh-blobs
as an [iroh
] [ProtocolHandler
].
This is the easiest way to share data from a crate::api::Store
over iroh connections.
§Example
use iroh::{protocol::Router, Endpoint};
use iroh_blobs::{net_protocol::Blobs, store};
// create a store
let store = store::fs::FsStore::load("blobs").await?;
// add some data
let t = store.add_slice(b"hello world").await?;
// create an iroh endpoint
let endpoint = Endpoint::builder().discovery_n0().bind().await?;
// create a blobs protocol handler
let blobs = Blobs::new(&store, endpoint.clone(), None);
// create a router and add the blobs protocol handler
let router = Router::builder(endpoint)
.accept(iroh_blobs::ALPN, blobs.clone())
.spawn();
// this data is now globally available using the ticket
let ticket = blobs.ticket(t).await?;
println!("ticket: {}", ticket);
// wait for control-c to exit
tokio::signal::ctrl_c().await?;
Structs§
- A protocol handler for the blobs protocol.