pub struct Bitswap { /* private fields */ }Expand description
Bitswap protocol handler
Implementations§
Source§impl Bitswap
impl Bitswap
Sourcepub async fn cancel_want(&self, cid: &Cid) -> Result<()>
pub async fn cancel_want(&self, cid: &Cid) -> Result<()>
Remove a CID from our want list
Sourcepub async fn get_want_list(&self) -> HashSet<Cid>
pub async fn get_want_list(&self) -> HashSet<Cid>
Get all CIDs we want
Sourcepub async fn get_have_list(&self) -> HashSet<Cid>
pub async fn get_have_list(&self) -> HashSet<Cid>
Get all CIDs we have
Sourcepub async fn request_block(&self, cid: Cid, peer: PeerId) -> Result<()>
pub async fn request_block(&self, cid: Cid, peer: PeerId) -> Result<()>
Request a block from a specific peer
Sourcepub async fn handle_message(
&self,
message: BitswapMessage,
from: PeerId,
) -> Result<Option<BitswapMessage>>
pub async fn handle_message( &self, message: BitswapMessage, from: PeerId, ) -> Result<Option<BitswapMessage>>
Handle incoming Bitswap message
Sourcepub async fn send_block(
&self,
cid: Cid,
data: Vec<u8>,
to: PeerId,
) -> Result<BitswapMessage>
pub async fn send_block( &self, cid: Cid, data: Vec<u8>, to: PeerId, ) -> Result<BitswapMessage>
Send a block to a peer
Sourcepub async fn get_pending_requests(&self, peer: &PeerId) -> HashSet<Cid>
pub async fn get_pending_requests(&self, peer: &PeerId) -> HashSet<Cid>
Get pending requests for a peer
Sourcepub async fn stats(&self) -> BitswapStats
pub async fn stats(&self) -> BitswapStats
Get Bitswap statistics
Sourcepub fn take_event_receiver(&mut self) -> Option<Receiver<BitswapEvent>>
pub fn take_event_receiver(&mut self) -> Option<Receiver<BitswapEvent>>
Take the event receiver
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bitswap
impl !RefUnwindSafe for Bitswap
impl Send for Bitswap
impl Sync for Bitswap
impl Unpin for Bitswap
impl !UnwindSafe for Bitswap
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more