Expand description
A ListenGroup
collects a set of network listeners, and the connections
they spawn, into a single abstraction, allowing them to easily share common
logic and data.
§Overview
The ListenGroup
is the central object in this crate. After
instantiation of a ListenGroup
the application can call
ListenGroup::add_listener()
to register new (network) listeners to it.
When one of the listeners has received a connection, it calls the
connected()
trait method of a
GroupHandler
implementor (which was passed to the ListenGroup
on
its creation).
The GroupHandler::connected()
implementor must return, among other
things, an object that implements ConnHandler
, which will be called
(through its ConnHandler::run()
method), to handle the connection.
§Per-listener context
The ListenGroup
uses a single GroupHandler
object for all listeners.
If the application needs per-listener-specific data, it can use an
associative container (like a HashMap
) in its GroupHandler
object to
map listeners’ unique identifiers to listener-specific contexts in the
container. See the per_listener_ctx
example in lstngrp’s repository for
an example implementation of this.
Structs§
- ArcId
Usize - An atomically referenced counted version of
IdUsize
. - CInfo
- Information returned about a connection when a listen group’s current state is inspected.
- Conn
Info - Context passed to
GroupHandler::connected()
used to pass connection (metadata) information. - Conn
Outcome - LInfo
- Information returned about registered listeners when getting a group listener’s current state.
- Listen
Group - Representation of a group of listeners.
- Listener
Spec - Builder for listeners to be added to a
ListenGroup
.
Enums§
- Listener
- Wrapper around common protocol-specific listener specifiers.
- Prot
Wrap Error - Crate-specific errors.
- Sock
Addr - Abstraction around std’s
SocketAddr
(for IPv4/IPv6) and tokio’s (unix local domain)SocketAddr
. - Stream
- Representation of a stream acting as a server end-point (passively established connection).
Traits§
- Conn
Handler - Implemented on types that should process client connections.
- Group
Handler - Group listener handler.