Trait NetworkView
pub trait NetworkView {
// Required methods
fn listening_as(&self) -> HashSet<Multiaddr>;
fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>;
fn discovered_peers(&self) -> HashSet<PeerId>;
fn connected_peers(&self) -> HashSet<PeerId>;
fn is_connected(&self, peer: &PeerId) -> bool;
fn health(&self) -> Health;
fn subscribe_network_events(
&self,
) -> impl Stream<Item = NetworkEvent> + Send + 'static;
}Expand description
Trait representing a read-only view of the network state.
Required Methods§
fn listening_as(&self) -> HashSet<Multiaddr>
fn listening_as(&self) -> HashSet<Multiaddr>
Multiaddresses used for listening by the local node.
fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>
fn multiaddress_of(&self, peer: &PeerId) -> Option<HashSet<Multiaddr>>
Translation of the peer into its known multiaddresses.
fn discovered_peers(&self) -> HashSet<PeerId>
fn discovered_peers(&self) -> HashSet<PeerId>
Peers collected by the network discovery mechanism.
fn connected_peers(&self) -> HashSet<PeerId>
fn connected_peers(&self) -> HashSet<PeerId>
Peers currently connected and tracked by the network.
fn is_connected(&self, peer: &PeerId) -> bool
fn is_connected(&self, peer: &PeerId) -> bool
Peers currently connected and tracked by the network.
fn subscribe_network_events(
&self,
) -> impl Stream<Item = NetworkEvent> + Send + 'static
fn subscribe_network_events( &self, ) -> impl Stream<Item = NetworkEvent> + Send + 'static
Subscribes to network events (peer connected/disconnected).
Each call creates a new independent subscription. Must be called before the network starts processing to avoid missing initial events.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.