| Crates.io | helia-block-brokers |
| lib.rs | helia-block-brokers |
| version | 0.1.3 |
| created_at | 2025-10-08 12:09:09.928135+00 |
| updated_at | 2025-10-11 04:11:17.868291+00 |
| description | Block broker abstractions for retrieving content from various sources |
| homepage | https://github.com/cyberfly-io/rust-helia |
| repository | https://github.com/cyberfly-io/rust-helia |
| max_upload_size | |
| id | 1873935 |
| size | 190,425 |
Block broker abstractions for coordinating block retrieval from multiple sources in Helia.
This crate provides the core traits and types for implementing block brokers - components that coordinate retrieving and announcing blocks across different protocols and sources.
use helia_block_brokers::{BlockBroker, BrokerStats, BlockRetrievalOptions};
use bytes::Bytes;
use cid::Cid;
// Implement the BlockBroker trait for your custom broker
#[async_trait::async_trait]
impl BlockBroker for MyCustomBroker {
async fn retrieve(&self, cid: Cid, options: BlockRetrievalOptions) -> Result<Bytes> {
// Your implementation here
}
async fn announce(&self, cid: Cid, data: Bytes, options: BlockAnnounceOptions) -> Result<()> {
// Your implementation here
}
async fn start(&self) -> Result<()> {
// Start broker
Ok(())
}
async fn stop(&self) -> Result<()> {
// Stop broker
Ok(())
}
fn get_stats(&self) -> BrokerStats {
// Return statistics
BrokerStats::default()
}
fn name(&self) -> &str {
"my-custom-broker"
}
}
The block broker abstraction allows for multiple implementation strategies:
This is a foundational package providing core abstractions. Concrete implementations will be added in future iterations.
Licensed under either of
at your option.