pub struct Connection { /* private fields */ }Expand description
Connection information.
Implementations§
Source§impl Connection
Implementation of Connection
impl Connection
Implementation of Connection
Sourcepub fn remote_addr(&self) -> Option<&SocketAddr>
pub fn remote_addr(&self) -> Option<&SocketAddr>
Get the remote address
Sourcepub fn local_addr(&self) -> Option<&SocketAddr>
pub fn local_addr(&self) -> Option<&SocketAddr>
Get the local address
pub fn config_data(&self) -> Option<&ClientConfig>
Sourcepub fn connection_type(&self) -> ConnType
pub fn connection_type(&self) -> ConnType
Get the connection type
Sourcepub fn is_outgoing(&self) -> bool
pub fn is_outgoing(&self) -> bool
Return true if this node initiated the connection (outbound dial).
gRPC inbound peers use Channel::Server; outbound dials use Channel::Client
with config_data set from ClientConfig.
WebSocket is asymmetric: the server accept path still uses Channel::Client for
writes, but leaves config_data unset, so inbound WebSocket is distinguished from
outbound WebSocket (which always carries config_data from the dial).
Sourcepub fn set_link_id(&mut self, link_id: String)
pub fn set_link_id(&mut self, link_id: String)
Set the shared link identifier for this connection.
Sourcepub fn remote_slim_version(&self) -> Option<Version>
pub fn remote_slim_version(&self) -> Option<Version>
Get the SLIM version of the remote peer.
Sourcepub fn peer_node_id(&self) -> Option<&str>
pub fn peer_node_id(&self) -> Option<&str>
Get the remote peer’s node identifier (set during link negotiation).
Sourcepub fn is_negotiated(&self) -> bool
pub fn is_negotiated(&self) -> bool
Returns true if link negotiation has completed (remote_slim_version is set).
Sourcepub fn complete_negotiation_as_server(
&mut self,
link_id: &str,
version: Version,
) -> bool
pub fn complete_negotiation_as_server( &mut self, link_id: &str, version: Version, ) -> bool
Complete link negotiation on the server (incoming) path.
Stores link_id and version. Returns false if link_id is empty or
negotiation is already complete (replay protection).
Sourcepub fn complete_negotiation_as_client(
&mut self,
link_id: &str,
version: Version,
) -> bool
pub fn complete_negotiation_as_client( &mut self, link_id: &str, version: Version, ) -> bool
Complete link negotiation on the client (outgoing) path.
Verifies the echoed link_id matches what was set, then stores version.
Returns false if there is a mismatch or negotiation is already complete.
Sourcepub fn with_negotiation(self, link_id: &str, version: &str) -> Self
pub fn with_negotiation(self, link_id: &str, version: &str) -> Self
Set negotiation state at construction time.
Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for Connection
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnsafeUnpin for Connection
impl UnwindSafe for Connection
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request