pub struct Listener { /* private fields */ }Expand description
One externally reachable messaging namespace.
A Listener is a namespace, not a socket and not a transport: it owns the endpoint routing table and nothing else (master doc §3). Credentials belong to the individual bindings, because they are transport-specific — a QUIC binding needs a certificate and key, a future in-process or adapter binding needs neither — and because two interfaces of one service may legitimately present different certificates.
Implementations§
Source§impl Listener
impl Listener
Sourcepub async fn bind_quic(
&self,
addr: SocketAddr,
tls: impl Into<ServerTls>,
) -> Result<Binding, Error>
pub async fn bind_quic( &self, addr: SocketAddr, tls: impl Into<ServerTls>, ) -> Result<Binding, Error>
Adds a native QUIC binding with its own server identity.
tls may be a bare crate::Identity — the binding then accepts
anonymous peers — or a ServerTls that also requires clients to
present an identity it trusts. The material is loaded and validated
here, so a misconfigured certificate fails before the socket serves
anything. Pass port 0 to let the OS choose; read it back with
Binding::local_addr.
Several bindings may serve the same Listener, each with its own identity: the endpoints they expose are the same, the identities they present need not be.
Sourcepub async fn bind_quic_socket(
&self,
socket: UdpSocket,
tls: impl Into<ServerTls>,
) -> Result<Binding, Error>
pub async fn bind_quic_socket( &self, socket: UdpSocket, tls: impl Into<ServerTls>, ) -> Result<Binding, Error>
Adds a native QUIC binding on a socket that is already bound.
For a process that received its socket rather than binding it: from
its predecessor over SCM_RIGHTS after Binding::hand_over, or
through socket activation. Otherwise it is exactly
Listener::bind_quic.
The socket is taken as it is: weida neither binds it nor sets options
on it, and Binding::local_addr reports the address it is bound to.
The socket is an OS socket, so a binding made here is never on a
simulated network.
A predecessor that called hand_over no longer reads the socket, so
the successor may serve it at once; it calls Binding::take_over
once its endpoints are registered.
Sourcepub fn bind_inproc(&self, bus: &str) -> Result<LocalBinding, Error>
pub fn bind_inproc(&self, bus: &str) -> Result<LocalBinding, Error>
Binds this Listener’s endpoints on an in-process bus.
The counterpart of Listener::bind_quic for the transport that has
no socket: weida+inproc://<bus>/<path> reaches the same endpoints
from the same process, with the same frames, the same HELLO and the
same negotiation, and without TLS or credentials
(docs/PROTOCOL.md §2.1,
decisions/0010
§4.1). The bus name is at most 256 bytes and unique within the
process; binding a name twice fails with
Error::AlreadyRegistered.
Sourcepub fn bind_unix(&self, path: impl AsRef<Path>) -> Result<UnixBinding, Error>
pub fn bind_unix(&self, path: impl AsRef<Path>) -> Result<UnixBinding, Error>
Binds this Listener’s endpoints on an AF_UNIX socket.
SOCK_STREAM on a filesystem path, no TLS and no credentials of our
own: the peer is proved by the kernel instead
(decisions/0010
§4.4, §4.5). A live listener on the path is refused
(ErrorKind::AddrInUse); a socket
file a crash left behind is replaced. The socket is bound in a private
0700 directory next to path, given mode 0600 there rather than
inheriting umask, and renamed into place, so it is never visible with
another mode. The directory is still what makes that safe:
whoever can write it can rename over the node afterwards
(docs/research/ipc.md §1.2, §7), so path MUST live in a directory
this process owns and no other user may write.
Connections are grouped into peers by decision 0012: the first connection is the peer, further ones carry its group token and are admitted only if the kernel credentials match.
Sourcepub fn replier(&self, path: &str) -> Result<Replier, Error>
pub fn replier(&self, path: &str) -> Result<Replier, Error>
Registers a replier for path.
The path must be a valid endpoint path and must not already be registered on this listener.
Sourcepub fn puller(&self, path: &str) -> Result<Puller, Error>
pub fn puller(&self, path: &str) -> Result<Puller, Error>
Registers a puller for path.
Pull binds and Push connects, mirroring Rep/Req. The path must be a valid endpoint path and must not already be registered on this listener, whatever pattern claimed it.
Sourcepub fn publisher(&self, path: &str) -> Result<Publisher, Error>
pub fn publisher(&self, path: &str) -> Result<Publisher, Error>
Registers a publisher for path.
Pub binds and Sub connects. Nothing inbound is accepted on the path — the registration claims it exclusively — and subscriptions that arrived before this call are already recorded, so a publisher created after its subscribers still reaches them.
Sourcepub fn radio(&self, path: &str) -> Result<Radio, Error>
pub fn radio(&self, path: &str) -> Result<Radio, Error>
Registers a radio for path
(decisions/0034 §4.6).
RADIO binds and DISH connects. Nothing inbound is accepted on the
path; a dish’s join is a SUBSCRIBE and lands in the radio. Every
segment goes to the dishes joined when it opens, and each copy is
dropped rather than waited for: by its successor, by the dish’s
max_age, or by the dish’s byte budget.
Sourcepub fn acceptor(&self, path: &str) -> Result<Acceptor, Error>
pub fn acceptor(&self, path: &str) -> Result<Acceptor, Error>
Registers a raw L0 acceptor for path.
Below the patterns: an acceptor takes both stream kinds on one path and
hands them over tagged (crate::Incoming), leaving the shape of the
conversation to the application. The path is claimed exactly like a
replier’s or a puller’s.
Sourcepub fn pair(&self, path: &str) -> Result<Paired, Error>
pub fn pair(&self, path: &str) -> Result<Paired, Error>
Registers a bound paired endpoint for path.
PAIR is one connection and one peer, carrying one-way transfers in
both directions (ARCHITECTURE.md
§6b). It adds no wire vocabulary: a paired endpoint talks to a
bare crate::Peer or Acceptor on the same path, which is the
test that proves the pattern layer is API and nothing else.
The one-peer rule is enforced at dispatch: the first connection to
send here claims the endpoint, and a stream from any other is refused
with LIMIT_EXCEEDED while the first keeps working.
Sourcepub fn respondent(&self, path: &str) -> Result<Respondent, Error>
pub fn respondent(&self, path: &str) -> Result<Respondent, Error>
Registers a respondent for path.
A survey question is an exchange, so a respondent’s route is byte-for-byte a replier’s: the same request route, the same accept queue, the same backpressure. What makes it a survey is entirely on the asking side — the fan-out and the deadline — so this pattern adds no routing and no wire vocabulary.
Sourcepub fn bus(
&self,
path: &str,
tls: impl Into<ClientTls>,
) -> Result<BusMember, Error>
pub fn bus( &self, path: &str, tls: impl Into<ClientTls>, ) -> Result<BusMember, Error>
Registers a bus member on path that dials the others on tls’s
terms.
The only factory that takes both a path and dialling terms,
because a bus member is the one role that is bound and dialling at
once (ARCHITECTURE.md §6b): it
accepts on its own path with a puller’s route and reaches the others
with crate::BusMember::connect.