1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// This file is part of the Aurelia workspace.
// SPDX-FileCopyrightText: 2026 Zivatar Limited
// SPDX-License-Identifier: Apache-2.0
use std::fmt;
use std::net::SocketAddr;
use std::path::PathBuf;
/// Network address of a domus peer, abstracting over the supported transports.
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub enum DomusAddr {
/// TCP socket address (used with mTLS).
Tcp(SocketAddr),
/// Unix domain socket path (used with peer-credential authentication).
Socket(PathBuf),
}
/// Tag identifying which transport a [`DomusAddr`] uses.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum TransportKind {
/// TCP transport with mTLS authentication.
Tcp,
/// Unix domain socket transport with peer-credential authentication.
Socket,
}
impl DomusAddr {
/// Returns the transport kind backing this address.
pub fn kind(&self) -> TransportKind {
match self {
DomusAddr::Tcp(_) => TransportKind::Tcp,
DomusAddr::Socket(_) => TransportKind::Socket,
}
}
/// Returns the underlying [`SocketAddr`] if this is a TCP address.
pub fn as_tcp(&self) -> Option<SocketAddr> {
match self {
DomusAddr::Tcp(addr) => Some(*addr),
_ => None,
}
}
}
impl fmt::Display for DomusAddr {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
DomusAddr::Tcp(addr) => write!(f, "tcp://{addr}"),
DomusAddr::Socket(path) => write!(f, "unix://{}", path.to_string_lossy()),
}
}
}
impl fmt::Display for TransportKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TransportKind::Tcp => write!(f, "tcp"),
TransportKind::Socket => write!(f, "socket"),
}
}
}