pub struct Listener<C: Codec<ByteBuffer> + Default + Clone> {
key_pair: KeyPair,
task_group: TaskGroup,
connection_slots: Arc<ConnectionSlots>,
conn_queue: Option<Arc<ConnQueue>>,
monitor: Arc<Monitor>,
_codec: PhantomData<C>,
}Expand description
Creates inbound connections with other peers. Generic over the
codec applied to the framed accepted streams so the same accept
machinery serves the peer data-plane (PeerNetMsgCodec) and the
kademlia lookup-plane (KadNetMsgCodec).
Fields§
§key_pair: KeyPair§task_group: TaskGroup§connection_slots: Arc<ConnectionSlots>§conn_queue: Option<Arc<ConnQueue>>§monitor: Arc<Monitor>§_codec: PhantomData<C>Implementations§
Source§impl<C> Listener<C>
impl<C> Listener<C>
Sourcepub fn new(
key_pair: &KeyPair,
connection_slots: Arc<ConnectionSlots>,
monitor: Arc<Monitor>,
ex: Executor,
) -> Arc<Self>
pub fn new( key_pair: &KeyPair, connection_slots: Arc<ConnectionSlots>, monitor: Arc<Monitor>, ex: Executor, ) -> Arc<Self>
Create a new Listener (no auto-queue; use start_with_callback).
Sourcepub async fn start_with_callback<Fut>(
self: &Arc<Self>,
endpoint: Endpoint,
callback: impl FnOnce(FramedConn<C>) -> Fut + Clone + Send + 'static,
) -> Result<Endpoint>
pub async fn start_with_callback<Fut>( self: &Arc<Self>, endpoint: Endpoint, callback: impl FnOnce(FramedConn<C>) -> Fut + Clone + Send + 'static, ) -> Result<Endpoint>
Start with a user-provided callback for each connection.
pub async fn shutdown(&self)
Sourceasync fn listen_loop_callback<Fut>(
self: Arc<Self>,
listener: StreamListener,
callback: impl FnOnce(FramedConn<C>) -> Fut + Clone + Send + 'static,
)
async fn listen_loop_callback<Fut>( self: Arc<Self>, listener: StreamListener, callback: impl FnOnce(FramedConn<C>) -> Fut + Clone + Send + 'static, )
Accept loop (callback mode).
Sourceasync fn listen(&self, endpoint: &Endpoint) -> Result<StreamListener>
async fn listen(&self, endpoint: &Endpoint) -> Result<StreamListener>
Create a listener for TCP/TLS.
Source§impl Listener<PeerNetMsgCodec>
impl Listener<PeerNetMsgCodec>
Sourcepub fn new_with_queue(
key_pair: &KeyPair,
connection_slots: Arc<ConnectionSlots>,
conn_queue: Arc<ConnQueue>,
monitor: Arc<Monitor>,
ex: Executor,
) -> Arc<Self>
pub fn new_with_queue( key_pair: &KeyPair, connection_slots: Arc<ConnectionSlots>, conn_queue: Arc<ConnQueue>, monitor: Arc<Monitor>, ex: Executor, ) -> Arc<Self>
Create a new Listener with a ConnQueue (auto-queue mode).
Sourcepub async fn start(self: &Arc<Self>, endpoint: Endpoint) -> Result<Endpoint>
pub async fn start(self: &Arc<Self>, endpoint: Endpoint) -> Result<Endpoint>
Start listening (auto-queue mode). Returns the resolved endpoint.
Sourceasync fn listen_loop(self: Arc<Self>, listener: StreamListener)
async fn listen_loop(self: Arc<Self>, listener: StreamListener)
Accept loop (auto-queue mode).
Sourceasync fn listen_loop_quic(self: Arc<Self>, quic_endpoint: QuicEndpoint)
async fn listen_loop_quic(self: Arc<Self>, quic_endpoint: QuicEndpoint)
QUIC accept loop.
Auto Trait Implementations§
impl<C> !Freeze for Listener<C>
impl<C> !RefUnwindSafe for Listener<C>
impl<C> Send for Listener<C>
impl<C> Sync for Listener<C>
impl<C> Unpin for Listener<C>where
C: Unpin,
impl<C> UnsafeUnpin for Listener<C>
impl<C> !UnwindSafe for Listener<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