pub struct UnixMgmtClient { /* private fields */ }Expand description
Single-shot typed Unix mgmt client. Each call opens a fresh
connection. Re-using one client for many calls works too — the
struct holds no persistent state across invocations.
Implementations§
Source§impl UnixMgmtClient
impl UnixMgmtClient
pub fn new(socket_path: impl AsRef<Path>) -> UnixMgmtClient
Sourcepub async fn call<A, R>(
&self,
verb: &str,
args: &A,
) -> Result<R, MgmtClientError>where
A: Serialize,
R: for<'de> Deserialize<'de>,
pub async fn call<A, R>(
&self,
verb: &str,
args: &A,
) -> Result<R, MgmtClientError>where
A: Serialize,
R: for<'de> Deserialize<'de>,
Send a verb + typed args, await typed result.
id is fixed at 1 for the single-request-per-connection
transport — there is no need for cross-process uniqueness on a
freshly-opened socket. A future multiplexed transport will own
its own id-allocation scheme.
§Errors
I/O failure (MgmtClientError::Io); a structured server-side
error (MgmtClientError::Server); or a JSON shape mismatch
when decoding either the response frame or the result payload
(MgmtClientError::Decode).
Sourcepub async fn call_stream<A, F>(
&self,
verb: &str,
args: &A,
on_event: F,
) -> Result<(), MgmtClientError>
pub async fn call_stream<A, F>( &self, verb: &str, args: &A, on_event: F, ) -> Result<(), MgmtClientError>
Send a streaming verb and consume each Event frame via
on_event until the server emits End, the connection drops, or
the server emits Error.
Unlike Self::call, this does not half-close the write
side of the socket — keeping the write half open lets the server
(or future operator-side cancellation logic) detect a clean
client disconnect via socket close.
§Errors
I/O failures, server-side Error frames, or a server-emitted
Result frame on what should be a streaming verb.