Helia

Trait Helia 

Source
pub trait Helia: Send + Sync {
Show 13 methods // Required methods fn blockstore(&self) -> &dyn Blocks; fn datastore(&self) -> &dyn Datastore; fn pins(&self) -> &dyn Pins; fn logger(&self) -> &dyn ComponentLogger; fn routing(&self) -> &dyn Routing; fn dns(&self) -> &TokioAsyncResolver; fn metrics(&self) -> Option<&dyn Metrics>; fn subscribe_events(&self) -> HeliaEventReceiver; fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn gc<'life0, 'async_trait>( &'life0 self, options: Option<GcOptions>, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_codec<'life0, 'async_trait>( &'life0 self, code: u64, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Codec>, HeliaError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_hasher<'life0, 'async_trait>( &'life0 self, code: u64, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Hasher>, HeliaError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Non-generic Helia trait for backward compatibility and trait objects

Required Methods§

Source

fn blockstore(&self) -> &dyn Blocks

The blockstore for storing blocks

Source

fn datastore(&self) -> &dyn Datastore

The datastore for key-value storage

Source

fn pins(&self) -> &dyn Pins

Pinning operations

Source

fn logger(&self) -> &dyn ComponentLogger

The logger component

Source

fn routing(&self) -> &dyn Routing

The routing component

Source

fn dns(&self) -> &TokioAsyncResolver

DNS resolver

Source

fn metrics(&self) -> Option<&dyn Metrics>

Optional metrics collector

Source

fn subscribe_events(&self) -> HeliaEventReceiver

Subscribe to events emitted by this Helia node

Returns a receiver that will receive all events emitted by the node. Multiple subscribers can listen to events simultaneously.

§Example
use helia_interface::{Helia, HeliaEvent};
 
let mut events_rx = helia.subscribe_events();
 
tokio::spawn(async move {
    while let Ok(event) = events_rx.recv().await {
        match event {
            HeliaEvent::Start => println!("Helia started"),
            HeliaEvent::Stop => println!("Helia stopped"),
            HeliaEvent::GcStarted => println!("GC started"),
            HeliaEvent::GcCompleted => println!("GC completed"),
        }
    }
});
Source

fn start<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Start the Helia node

Source

fn stop<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stop the Helia node

Source

fn gc<'life0, 'async_trait>( &'life0 self, options: Option<GcOptions>, ) -> Pin<Box<dyn Future<Output = Result<(), HeliaError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform garbage collection

Source

fn get_codec<'life0, 'async_trait>( &'life0 self, code: u64, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Codec>, HeliaError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load an IPLD codec

Source

fn get_hasher<'life0, 'async_trait>( &'life0 self, code: u64, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Hasher>, HeliaError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Load a hasher

Implementors§