Struct libp2p_swarm::dial_opts::DialOpts
source · pub struct DialOpts(_);
Expand description
Options to configure a dial to a known or unknown peer.
Used in Swarm::dial
and
NetworkBehaviourAction::Dial
.
To construct use either of:
-
DialOpts::peer_id
dialing a known peer -
DialOpts::unknown_peer_id
dialing an unknown peer
Implementations§
source§impl DialOpts
impl DialOpts
sourcepub fn peer_id(peer_id: PeerId) -> WithPeerId
pub fn peer_id(peer_id: PeerId) -> WithPeerId
Dial a known peer.
DialOpts::peer_id(PeerId::random())
.condition(PeerCondition::Disconnected)
.addresses(vec!["/ip6/::1/tcp/12345".parse().unwrap()])
.extend_addresses_through_behaviour()
.build();
sourcepub fn unknown_peer_id() -> WithoutPeerId
pub fn unknown_peer_id() -> WithoutPeerId
Dial an unknown peer.
DialOpts::unknown_peer_id()
.address("/ip6/::1/tcp/12345".parse().unwrap())
.build();