pub struct NetworkHost { /* private fields */ }Expand description
Network host providing high-level network operations.
Implementations§
Source§impl NetworkHost
impl NetworkHost
Sourcepub async fn start(config: HostConfig) -> NetworkResult<Self>
pub async fn start(config: HostConfig) -> NetworkResult<Self>
Create and start a new network host.
Sourcepub async fn peer_info(&self) -> NetworkResult<PeerInfo>
pub async fn peer_info(&self) -> NetworkResult<PeerInfo>
Get peer info.
Sourcepub async fn connected_peers(&self) -> NetworkResult<Vec<ConnectedPeer>>
pub async fn connected_peers(&self) -> NetworkResult<Vec<ConnectedPeer>>
Get connected peers.
Sourcepub async fn connect(&self, addr: &str) -> NetworkResult<()>
pub async fn connect(&self, addr: &str) -> NetworkResult<()>
Connect to a peer.
Sourcepub async fn disconnect(&self, peer: &str) -> NetworkResult<()>
pub async fn disconnect(&self, peer: &str) -> NetworkResult<()>
Disconnect from a peer.
Sourcepub async fn known_addresses(
&self,
) -> NetworkResult<HashMap<String, Vec<String>>>
pub async fn known_addresses( &self, ) -> NetworkResult<HashMap<String, Vec<String>>>
Get known addresses for all peers.
Sourcepub async fn ping(&self, peer: &str) -> NetworkResult<PingResult>
pub async fn ping(&self, peer: &str) -> NetworkResult<PingResult>
Ping a peer.
Sourcepub async fn listen_addresses(&self) -> NetworkResult<Vec<String>>
pub async fn listen_addresses(&self) -> NetworkResult<Vec<String>>
Get listen addresses.
Sourcepub async fn shutdown(&self) -> NetworkResult<()>
pub async fn shutdown(&self) -> NetworkResult<()>
Shutdown the host.
Sourcepub async fn find_providers(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
pub async fn find_providers(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
Find providers for content.
Sourcepub async fn find_peer(&self, peer: &str) -> NetworkResult<DhtQueryResult>
pub async fn find_peer(&self, peer: &str) -> NetworkResult<DhtQueryResult>
Find a peer in the DHT.
Sourcepub async fn provide(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
pub async fn provide(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
Announce content to the DHT.
Sourcepub async fn put_value(
&self,
key: &[u8],
value: Vec<u8>,
) -> NetworkResult<DhtQueryResult>
pub async fn put_value( &self, key: &[u8], value: Vec<u8>, ) -> NetworkResult<DhtQueryResult>
Put a value in the DHT.
Sourcepub async fn get_value(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
pub async fn get_value(&self, key: &[u8]) -> NetworkResult<DhtQueryResult>
Get a value from the DHT.
Sourcepub async fn dht_stats(&self) -> NetworkResult<DhtStats>
pub async fn dht_stats(&self) -> NetworkResult<DhtStats>
Get DHT statistics.
Sourcepub async fn bootstrap(&self) -> NetworkResult<()>
pub async fn bootstrap(&self) -> NetworkResult<()>
Bootstrap the DHT.
Auto Trait Implementations§
impl Freeze for NetworkHost
impl !RefUnwindSafe for NetworkHost
impl Send for NetworkHost
impl Sync for NetworkHost
impl Unpin for NetworkHost
impl !UnwindSafe for NetworkHost
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