pub struct HttpMgmtClient { /* private fields */ }Expand description
Plaintext HTTP/1.1 mgmt client. Cheap to clone — addr is Copy,
token is reference-counted.
Implementations§
Source§impl HttpMgmtClient
impl HttpMgmtClient
Sourcepub fn new(addr: SocketAddr, token: Option<Arc<str>>) -> HttpMgmtClient
pub fn new(addr: SocketAddr, token: Option<Arc<str>>) -> HttpMgmtClient
Build a client targeting the given HTTP endpoint. The token
argument matches the server’s bearer_token setting: pass
None only when the server is configured for anonymous access.
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>,
One-shot verb call. Mirrors crate::UnixMgmtClient::call.
§Errors
I/O failure (MgmtClientError::Io); a non-200 HTTP response
(MgmtClientError::Http — 401 for missing / wrong token,
400 / 404 / 405 / 413 for malformed requests); a
structured server-side error frame (MgmtClientError::Server);
or a JSON shape mismatch (MgmtClientError::Decode).
Sourcepub async fn stream<A, F>(
&self,
verb: &str,
args: &A,
on_event: F,
) -> Result<(), MgmtClientError>
pub async fn stream<A, F>( &self, verb: &str, args: &A, on_event: F, ) -> Result<(), MgmtClientError>
Streaming verb call. Invokes on_event for each Event frame,
returns when the server emits End, the connection drops, or
the server emits Error.
§Errors
Same shape as Self::call, plus the streaming-specific case
where the server emits a Result frame on what should be a
streaming verb.
Trait Implementations§
Source§impl Clone for HttpMgmtClient
impl Clone for HttpMgmtClient
Source§fn clone(&self) -> HttpMgmtClient
fn clone(&self) -> HttpMgmtClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more