pub struct BusClient { /* private fields */ }Expand description
The IPC bus client used by each daemon to communicate on the bus.
Implementations§
Source§impl BusClient
impl BusClient
Sourcepub fn new(
daemon_id: DaemonId,
outbound_tx: Sender<Vec<u8>>,
inbound_rx: Receiver<Vec<u8>>,
) -> Self
pub fn new( daemon_id: DaemonId, outbound_tx: Sender<Vec<u8>>, inbound_rx: Receiver<Vec<u8>>, ) -> Self
Create a new bus client with pre-wired channels (for in-process testing).
Sourcepub async fn connect_encrypted(
daemon_id: DaemonId,
path: &Path,
server_public_key: &[u8; 32],
client_keypair: &Keypair,
) -> Result<Self>
pub async fn connect_encrypted( daemon_id: DaemonId, path: &Path, server_public_key: &[u8; 32], client_keypair: &Keypair, ) -> Result<Self>
Connect to the bus server with Noise IK encrypted transport.
Low-level constructor used by tests and connect_with_keypair_retry.
Does NOT handle key rotation — the I/O task is a plain byte pipe.
Production daemons should use connect_daemon_with_keypair_retry instead.
§Errors
Returns an error if connection, key read, or handshake fails.
Sourcepub async fn send(&self, msg: &Message<EventKind>) -> Result<()>
pub async fn send(&self, msg: &Message<EventKind>) -> Result<()>
Send a message to the bus server.
§Errors
Returns an error if serialization fails or the connection is closed.
Sourcepub async fn publish(
&self,
event: EventKind,
security_level: SecurityLevel,
) -> Result<()>
pub async fn publish( &self, event: EventKind, security_level: SecurityLevel, ) -> Result<()>
Publish an event to the bus.
§Errors
Returns an error if serialization fails or the outbound channel is closed.
Sourcepub async fn request(
&self,
event: EventKind,
security_level: SecurityLevel,
timeout: Duration,
) -> Result<Message<EventKind>>
pub async fn request( &self, event: EventKind, security_level: SecurityLevel, timeout: Duration, ) -> Result<Message<EventKind>>
Send a request and wait for a correlated response.
§Errors
Returns an error on send failure or timeout.
Sourcepub async fn recv(&mut self) -> Option<Message<EventKind>>
pub async fn recv(&mut self) -> Option<Message<EventKind>>
Receive the next broadcast/unsolicited inbound event.
Returns None if the server disconnected.
Sourcepub fn set_installation(&mut self, installation: InstallationId)
pub fn set_installation(&mut self, installation: InstallationId)
Set the installation identity on the message context.
Sourcepub async fn shutdown(self)
pub async fn shutdown(self)
Gracefully shut down the client, flushing all pending outbound frames.
Sourcepub async fn connect_with_keypair_retry(
daemon_name: &str,
daemon_id: DaemonId,
socket_path: &Path,
server_pub: &[u8; 32],
max_attempts: u32,
backoff: Duration,
) -> Result<(Self, ZeroizingKeypair)>
pub async fn connect_with_keypair_retry( daemon_name: &str, daemon_id: DaemonId, socket_path: &Path, server_pub: &[u8; 32], max_attempts: u32, backoff: Duration, ) -> Result<(Self, ZeroizingKeypair)>
Connect to the IPC bus with keypair re-read on each attempt.
Low-level retry constructor for CLI clients and tests.
Does NOT handle key rotation. Production daemons should use
connect_daemon_with_keypair_retry.
§Errors
Returns an error if all attempts fail (keypair read or connect).
Sourcepub async fn connect_daemon_with_keypair_retry(
daemon_name: &str,
daemon_id: DaemonId,
socket_path: &Path,
server_pub: &[u8; 32],
capabilities: Vec<String>,
version: &str,
retry: RetryConfig,
) -> Result<Self>
pub async fn connect_daemon_with_keypair_retry( daemon_name: &str, daemon_id: DaemonId, socket_path: &Path, server_pub: &[u8; 32], capabilities: Vec<String>, version: &str, retry: RetryConfig, ) -> Result<Self>
Connect to the IPC bus as a named daemon with transparent key rotation.
Same retry logic as connect_with_keypair_retry, but the returned
client’s I/O task automatically handles KeyRotationPending messages.
The caller never sees rotation events and recv() is uninterrupted.
The initial DaemonStarted announcement is NOT sent by this method —
the caller publishes it after connecting.
§Errors
Returns an error if all connection attempts fail.