pub struct Listener {
key_pair: KeyPair,
task_group: TaskGroup,
connection_slots: Arc<ConnectionSlots>,
enable_tls: bool,
monitor: Arc<Monitor>,
}Expand description
Responsible for creating inbound connections with other peers.
Fields§
§key_pair: KeyPairIdentity Key pair
task_group: TaskGroupManaging spawned tasks.
connection_slots: Arc<ConnectionSlots>Manages available inbound slots.
enable_tls: boolEnables secure connection.
monitor: Arc<Monitor>Responsible for network and system monitoring.
Implementations§
Source§impl Listener
impl Listener
Sourcepub fn new(
key_pair: &KeyPair,
connection_slots: Arc<ConnectionSlots>,
enable_tls: bool,
monitor: Arc<Monitor>,
ex: Executor,
) -> Arc<Self>
pub fn new( key_pair: &KeyPair, connection_slots: Arc<ConnectionSlots>, enable_tls: bool, monitor: Arc<Monitor>, ex: Executor, ) -> Arc<Self>
Creates a new Listener
Sourcepub async fn start<Fut>(
self: &Arc<Self>,
endpoint: Endpoint,
callback: impl FnOnce(Conn<NetMsg, Error>) -> Fut + Clone + Send + 'static,
) -> Result<Endpoint>
pub async fn start<Fut>( self: &Arc<Self>, endpoint: Endpoint, callback: impl FnOnce(Conn<NetMsg, Error>) -> Fut + Clone + Send + 'static, ) -> Result<Endpoint>
Starts a listener on the given endpoint. For each incoming connection
that is accepted, it invokes the provided callback, and pass the
connection to the callback.
Returns the resloved listening endpoint.
async fn listen_loop<Fut>( self: Arc<Self>, listener: Listener<NetMsg, Error>, callback: impl FnOnce(Conn<NetMsg, Error>) -> Fut + Clone + Send + 'static, )
async fn listen(&self, endpoint: &Endpoint) -> Result<Listener<NetMsg, Error>>
Auto Trait Implementations§
impl !Freeze for Listener
impl !RefUnwindSafe for Listener
impl Send for Listener
impl Sync for Listener
impl Unpin for Listener
impl !UnwindSafe for Listener
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