pub trait WithBitswap {
// Required methods
fn bitswap_mut(&mut self) -> &mut dyn Any;
fn bitswap(&self) -> &dyn Any;
}Expand description
Trait for NetworkBehaviours that include Bitswap
This trait allows Helia to work with any custom NetworkBehaviour that includes
a BitswapBehaviour field. By implementing this trait, applications can share
their custom swarm with Helia instead of running separate connections.
§Example
ⓘ
use libp2p::swarm::NetworkBehaviour;
use helia_bitswap::BitswapBehaviour;
use helia_interface::WithBitswap;
#[derive(NetworkBehaviour)]
pub struct MyBehaviour {
pub gossipsub: gossipsub::Behaviour,
pub bitswap: BitswapBehaviour,
}
impl WithBitswap for MyBehaviour {
fn bitswap_mut(&mut self) -> &mut BitswapBehaviour {
&mut self.bitswap
}
fn bitswap(&self) -> &BitswapBehaviour {
&self.bitswap
}
}Required Methods§
Sourcefn bitswap_mut(&mut self) -> &mut dyn Any
fn bitswap_mut(&mut self) -> &mut dyn Any
Get a mutable reference to the BitswapBehaviour