pub struct PeerConnection { /* private fields */ }Expand description
Request handle for an active peer connection
Implementations§
Source§impl PeerConnection
impl PeerConnection
Sourcepub fn strong_count(&self) -> usize
pub fn strong_count(&self) -> usize
Number of strong handles currently outstanding on this connection (shared across all clones). Used by reapers to decide whether the peer is currently pinned by a strong owner.
Sourcepub fn is_strongly_held(&self) -> bool
pub fn is_strongly_held(&self) -> bool
true if any clone of this connection is currently being held as a strong reference.
Sourcepub fn is_strong(&self) -> bool
pub fn is_strong(&self) -> bool
true if this handle is the strong kind (i.e. it contributes to strong_count).
Sourcepub fn clone_strong(&self) -> Self
pub fn clone_strong(&self) -> Self
Returns a new strong clone of this connection. Increments the shared strong counter, regardless of whether the source handle is itself strong.
Sourcepub fn clone_weak(&self) -> Self
pub fn clone_weak(&self) -> Self
Returns a new weak clone of this connection. Does not touch the strong counter even if the source handle is strong.
Sourcepub fn clone_with(&self, kind: RefKind) -> Self
pub fn clone_with(&self, kind: RefKind) -> Self
Returns a clone whose ref-kind is determined by kind. Convenience wrapper used by the
connectivity layer to honour caller-requested RefKind without branching at the call
site.
pub fn peer_node_id(&self) -> &NodeId
pub fn peer_features(&self) -> PeerFeatures
pub fn direction(&self) -> ConnectionDirection
pub fn known_address(&self) -> Option<&Multiaddr>
pub fn address(&self) -> &Multiaddr
pub fn id(&self) -> ConnectionId
pub fn is_connected(&self) -> bool
Sourcepub fn on_disconnect(&self) -> impl Future<Output = ()> + 'static
pub fn on_disconnect(&self) -> impl Future<Output = ()> + 'static
Returns a owned future that resolves on disconnection
pub fn age(&self) -> Duration
pub fn substream_count(&self) -> usize
pub fn handle_count(&self) -> usize
pub async fn open_substream( &mut self, protocol_id: &ProtocolId, ) -> Result<NegotiatedSubstream<Substream>, PeerConnectionError>
pub async fn open_framed_substream( &mut self, protocol_id: &ProtocolId, max_frame_size: usize, ) -> Result<CanonicalFraming<Substream>, PeerConnectionError>
Sourcepub async fn disconnect(
&mut self,
minimized: Minimized,
requester: &str,
) -> Result<(), PeerConnectionError>
pub async fn disconnect( &mut self, minimized: Minimized, requester: &str, ) -> Result<(), PeerConnectionError>
Immediately disconnects the peer connection. This can only fail if the peer connection worker is shut down (and the peer is already disconnected)
Sourcepub async fn disconnect_if_unused(
&mut self,
minimized: Minimized,
expected_rpc: usize,
expected_substreams: usize,
requester: &str,
) -> Result<(), PeerConnectionError>
pub async fn disconnect_if_unused( &mut self, minimized: Minimized, expected_rpc: usize, expected_substreams: usize, requester: &str, ) -> Result<(), PeerConnectionError>
Request to disconnect the peer connection if unused by other services.
Sourcepub fn set_force_disconnect_rpc_clients_when_clone_drops(&mut self)
pub fn set_force_disconnect_rpc_clients_when_clone_drops(&mut self)
Forcefully disconnect all RPC clients when any clone is dropped - if not set (the default behaviour) all RPC
clients will be disconnected when the last instance is dropped. i.e. when self.handle_counter == 1
Trait Implementations§
Source§impl Clone for PeerConnection
impl Clone for PeerConnection
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Clones preserve the source handle’s strength (Arc-like). A clone of a strong handle is
itself strong and bumps the shared strong counter; a clone of a weak handle is weak. Use
PeerConnection::clone_strong / PeerConnection::clone_weak to switch kinds
explicitly.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PeerConnection
impl Debug for PeerConnection
Source§impl Display for PeerConnection
impl Display for PeerConnection
Source§impl Drop for PeerConnection
impl Drop for PeerConnection
Auto Trait Implementations§
impl !RefUnwindSafe for PeerConnection
impl !UnwindSafe for PeerConnection
impl Freeze for PeerConnection
impl Send for PeerConnection
impl Sync for PeerConnection
impl Unpin for PeerConnection
impl UnsafeUnpin for PeerConnection
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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<'a, T> DefaultFeatures<'a> for T
impl<'a, T> DefaultFeatures<'a> for T
Source§fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>
fn clone_boxed(&self) -> Box<dyn DefaultFeatures<'a>>
Box
behind a trait object of this trait.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
impl<'a, T> NonSyncFeatures<'a> for Twhere
T: 'a + Clone,
Source§fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>
fn clone_boxed(&self) -> Box<dyn NonSyncFeatures<'a>>
Box
behind a trait object of this trait.