Struct splinter::peer::PeerManagerConnector
source · [−]pub struct PeerManagerConnector { /* private fields */ }
Expand description
The PeerManagerConnector
will be used to make requests to the PeerManager
.
The connector includes functions to add a new peer reference, update a peer and list the existing peers.
Implementations
sourceimpl PeerManagerConnector
impl PeerManagerConnector
sourcepub fn add_peer_ref(
&self,
peer_id: PeerAuthorizationToken,
endpoints: Vec<String>,
required_local_auth: PeerAuthorizationToken
) -> Result<PeerRef, PeerRefAddError>
pub fn add_peer_ref(
&self,
peer_id: PeerAuthorizationToken,
endpoints: Vec<String>,
required_local_auth: PeerAuthorizationToken
) -> Result<PeerRef, PeerRefAddError>
Requests that a peer is added to the PeerManager
. If a peer already exists, the peer’s
reference count will be incremented
Returns a PeerRef
that, when dropped, will automatically send a removal request to the
PeerManager
.
Arguments
peer_id
- The unique PeerAuthorizationToken for the peer.endpoints
- The list of endpoints associated with the peer. The list should be in order of preference, with the first endpoint being the first attempted.required_local_auth
- The local authorization that must be used to identify the local node during authorization.
sourcepub fn add_unidentified_peer(
&self,
endpoint: String,
local_authorization: PeerAuthorizationToken
) -> Result<EndpointPeerRef, PeerUnknownAddError>
pub fn add_unidentified_peer(
&self,
endpoint: String,
local_authorization: PeerAuthorizationToken
) -> Result<EndpointPeerRef, PeerUnknownAddError>
Requests that a peer is added to the PeerManager
. This function should be used when the
peer ID is unknown.
Returns Ok(EndpointPeerRef)
if the unidentified peer was added
Arguments
endpoint
- The endpoint associated with the peer.local_authorization
- The required PeerAuthorizationToken that will be used to identify- the local node.
sourcepub fn list_peers(&self) -> Result<Vec<PeerAuthorizationToken>, PeerListError>
pub fn list_peers(&self) -> Result<Vec<PeerAuthorizationToken>, PeerListError>
Requests the list of currently connected peers.
Returns the list of peer IDs.
sourcepub fn list_unreferenced_peers(
&self
) -> Result<Vec<PeerTokenPair>, PeerListError>
pub fn list_unreferenced_peers(
&self
) -> Result<Vec<PeerTokenPair>, PeerListError>
Requests the list of unreferenced peers.
Unreferenced peers are those peers that have successfully connected from a remote node, but have not yet been referenced by a circuit. These peers are available to be promoted to fully refrerenced peers.
sourcepub fn connection_ids(
&self
) -> Result<BiHashMap<PeerTokenPair, String>, PeerConnectionIdError>
pub fn connection_ids(
&self
) -> Result<BiHashMap<PeerTokenPair, String>, PeerConnectionIdError>
Requests the map of currently connected peers to connection IDs
Returns a map of peer IDs to connection IDs
sourcepub fn subscribe(&self) -> Result<PeerNotificationIter, PeerManagerError>
👎 Deprecated since 0.5.1: please use subscribe_sender
instead
pub fn subscribe(&self) -> Result<PeerNotificationIter, PeerManagerError>
please use subscribe_sender
instead
Subscribes to PeerManager
notifications.
Returns a PeerNotificationIter
that can be used to receive notifications about connected
and disconnected peers
sourcepub fn subscribe_sender<T>(
&self,
subscriber: Sender<T>
) -> Result<SubscriberId, PeerManagerError> where
T: From<PeerManagerNotification> + Send + 'static,
pub fn subscribe_sender<T>(
&self,
subscriber: Sender<T>
) -> Result<SubscriberId, PeerManagerError> where
T: From<PeerManagerNotification> + Send + 'static,
Subscribe to notifications for peer events.
PeerManagerNotification
instances will be transformed via type T
’s implementation
of From<PeerManagerNotification>
and passed to the given sender.
Returns
The subscriber ID that can be used for unsubscribing the given sender.
Errors
Return a PeerManagerError
if the subscriber cannot be registered via the
PeerManagerConnector
instance.
sourcepub fn unsubscribe(
&self,
subscriber_id: SubscriberId
) -> Result<(), PeerManagerError>
pub fn unsubscribe(
&self,
subscriber_id: SubscriberId
) -> Result<(), PeerManagerError>
Unsubscribe from PeerManagerNotification
.
Errors
Returns a PeerManagerError
if the PeerManager
has stopped running.
Trait Implementations
sourceimpl Clone for PeerManagerConnector
impl Clone for PeerManagerConnector
sourcefn clone(&self) -> PeerManagerConnector
fn clone(&self) -> PeerManagerConnector
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PeerManagerConnector
impl Debug for PeerManagerConnector
sourceimpl PeerLookup for PeerManagerConnector
impl PeerLookup for PeerManagerConnector
sourcefn connection_id(
&self,
peer_id: &PeerTokenPair
) -> Result<Option<String>, PeerLookupError>
fn connection_id(
&self,
peer_id: &PeerTokenPair
) -> Result<Option<String>, PeerLookupError>
Retrieves the connection ID for a given peer ID, if found. Read more
Auto Trait Implementations
impl !RefUnwindSafe for PeerManagerConnector
impl Send for PeerManagerConnector
impl !Sync for PeerManagerConnector
impl Unpin for PeerManagerConnector
impl !UnwindSafe for PeerManagerConnector
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<P, N> IntoBytes<P> for N where
P: Message + FromNative<N>,
impl<P, N> IntoBytes<P> for N where
P: Message + FromNative<N>,
fn into_bytes(self) -> Result<Vec<u8, Global>, ProtoConversionError>
sourceimpl<N, P> IntoNative<N> for P where
N: FromProto<P>,
impl<N, P> IntoNative<N> for P where
N: FromProto<P>,
fn into_native(self) -> Result<N, ProtoConversionError>
sourceimpl<N, P> IntoProto<P> for N where
P: FromNative<N>,
impl<N, P> IntoProto<P> for N where
P: FromNative<N>,
fn into_proto(self) -> Result<P, ProtoConversionError>
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
fn into_sql<T>(self) -> Self::Expression where
Self: AsExpression<T>,
Convert self
to an expression for Diesel’s query builder. Read more
sourcefn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel’s query builder. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more