pub struct Connector<C: Codec<ByteBuffer> + Default + Clone> {
key_pair: KeyPair,
task_group: TaskGroup,
connection_slots: Arc<ConnectionSlots>,
max_retries: usize,
conn_queue: Option<Arc<ConnQueue>>,
monitor: Arc<Monitor>,
_codec: PhantomData<C>,
}Expand description
Creates outbound connections with other peers. Generic over the
codec applied to the resulting framed stream so the same machinery
(TLS, retries, slots, monitor events) serves both the peer
data-plane (PeerNetMsgCodec) and the kademlia lookup-plane
(KadNetMsgCodec).
Fields§
§key_pair: KeyPair§task_group: TaskGroup§connection_slots: Arc<ConnectionSlots>§max_retries: usize§conn_queue: Option<Arc<ConnQueue>>§monitor: Arc<Monitor>§_codec: PhantomData<C>Implementations§
Source§impl<C> Connector<C>
impl<C> Connector<C>
Sourcepub fn new(
key_pair: &KeyPair,
max_retries: usize,
connection_slots: Arc<ConnectionSlots>,
monitor: Arc<Monitor>,
ex: Executor,
) -> Arc<Self>
pub fn new( key_pair: &KeyPair, max_retries: usize, connection_slots: Arc<ConnectionSlots>, monitor: Arc<Monitor>, ex: Executor, ) -> Arc<Self>
Create a new Connector without a ConnQueue (used for plain
connect paths like Kademlia lookup).
pub async fn shutdown(&self)
Sourcepub async fn connect(
&self,
endpoint: &Endpoint,
peer_id: &Option<PeerID>,
) -> Result<FramedConn<C>>
pub async fn connect( &self, endpoint: &Endpoint, peer_id: &Option<PeerID>, ) -> Result<FramedConn<C>>
Connect and return the framed connection.
Sourceasync fn connect_internal(
&self,
endpoint: &Endpoint,
peer_id: &Option<PeerID>,
) -> Result<DialResult<C>>
async fn connect_internal( &self, endpoint: &Endpoint, peer_id: &Option<PeerID>, ) -> Result<DialResult<C>>
Dial with retries.
Auto Trait Implementations§
impl<C> !Freeze for Connector<C>
impl<C> !RefUnwindSafe for Connector<C>
impl<C> Send for Connector<C>
impl<C> Sync for Connector<C>
impl<C> Unpin for Connector<C>where
C: Unpin,
impl<C> UnsafeUnpin for Connector<C>
impl<C> !UnwindSafe for Connector<C>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Mutably borrows from an owned value. Read more