BusClient

Struct BusClient 

Source
pub struct BusClient { /* private fields */ }
Expand description

The IPC bus client used by each daemon to communicate on the bus.

Implementations§

Source§

impl BusClient

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn recv(&mut self) -> Option<Message<EventKind>>

Receive the next broadcast/unsolicited inbound event.

Returns None if the server disconnected.

Source

pub fn daemon_id(&self) -> DaemonId

Return this client’s daemon ID.

Source

pub fn epoch(&self) -> Instant

Return the client’s monotonic epoch.

Source

pub fn set_installation(&mut self, installation: InstallationId)

Set the installation identity on the message context.

Source

pub async fn shutdown(self)

Gracefully shut down the client, flushing all pending outbound frames.

Source

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).

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more