pub enum ConnectedPoint {
    Dialer {
        address: Multiaddr,
        role_override: Endpoint,
    },
    Listener {
        local_addr: Multiaddr,
        send_back_addr: Multiaddr,
    },
}
Expand description

The endpoint roles associated with an established peer-to-peer connection.

Variants§

§

Dialer

Fields

§address: Multiaddr

Multiaddress that was successfully dialed.

§role_override: Endpoint

Whether the role of the local node on the connection should be overriden. I.e. whether the local node should act as a listener on the outgoing connection.

This option is needed for NAT and firewall hole punching.

  • Endpoint::Dialer represents the default non-overriding option.

  • Endpoint::Listener represents the overriding option. Realization depends on the transport protocol. E.g. in the case of TCP, both endpoints dial each other, resulting in a simultaneous open TCP connection. On this new connection both endpoints assume to be the dialer of the connection. This is problematic during the connection upgrade process where an upgrade assumes one side to be the listener. With the help of this option, both peers can negotiate the roles (dialer and listener) for the new connection ahead of time, through some external channel, e.g. the DCUtR protocol, and thus have one peer dial the other and upgrade the connection as a dialer and one peer dial the other and upgrade the connection as a listener overriding its role.

We dialed the node.

§

Listener

Fields

§local_addr: Multiaddr

Local connection address.

§send_back_addr: Multiaddr

Address used to send back data to the remote.

We received the node.

Implementations§

source§

impl ConnectedPoint

source

pub fn to_endpoint(&self) -> Endpoint

Turns the ConnectedPoint into the corresponding Endpoint.

source

pub fn is_dialer(&self) -> bool

Returns true if we are Dialer.

source

pub fn is_listener(&self) -> bool

Returns true if we are Listener.

source

pub fn is_relayed(&self) -> bool

Returns true if the connection is relayed.

source

pub fn get_remote_address(&self) -> &Multiaddr

Returns the address of the remote stored in this struct.

For Dialer, this returns address. For Listener, this returns send_back_addr.

Note that the remote node might not be listening on this address and hence the address might not be usable to establish new connections.

source

pub fn set_remote_address(&mut self, new_address: Multiaddr)

Modifies the address of the remote stored in this struct.

For Dialer, this modifies address. For Listener, this modifies send_back_addr.

Trait Implementations§

source§

impl Clone for ConnectedPoint

source§

fn clone(&self) -> ConnectedPoint

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ConnectedPoint

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&ConnectedPoint> for Endpoint

source§

fn from(endpoint: &ConnectedPoint) -> Endpoint

Converts to this type from the input type.
source§

impl From<ConnectedPoint> for Endpoint

source§

fn from(endpoint: ConnectedPoint) -> Endpoint

Converts to this type from the input type.
source§

impl Hash for ConnectedPoint

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for ConnectedPoint

source§

fn eq(&self, other: &ConnectedPoint) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for ConnectedPoint

source§

impl StructuralEq for ConnectedPoint

source§

impl StructuralPartialEq for ConnectedPoint

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more