pub struct TypedClient<C, M> { /* private fields */ }Expand description
A strongly-typed view over any Client, carrying a
StateMachine’s command/query/response types so callers work with real
Rust values instead of postcard byte vectors.
let typed: TypedClient<RemoteClient, KvMachine> = TypedClient::new(remote);
let resp = typed.propose(&KvCommand::Set { key, value }).await?;Implementations§
Source§impl<C, M> TypedClient<C, M>
impl<C, M> TypedClient<C, M>
Source§impl<C: Client, M: StateMachine> TypedClient<C, M>
impl<C: Client, M: StateMachine> TypedClient<C, M>
Sourcepub async fn propose(
&self,
command: &M::Command,
) -> Result<M::Response, ClientError>
pub async fn propose( &self, command: &M::Command, ) -> Result<M::Response, ClientError>
Propose a typed command and decode the typed response.
§Errors
ClientError::Codec if the command cannot be encoded or the response
cannot be decoded, otherwise any error from the underlying Client.
Sourcepub async fn query(&self, query: &M::Query) -> Result<M::Response, ClientError>
pub async fn query(&self, query: &M::Query) -> Result<M::Response, ClientError>
Run a typed linearizable query and decode the typed response.
§Errors
ClientError::Codec if the query cannot be encoded or the response
cannot be decoded, otherwise any error from the underlying Client.
Source§impl<C: KeyedClient, M: StateMachine> TypedClient<C, M>
impl<C: KeyedClient, M: StateMachine> TypedClient<C, M>
Sourcepub async fn propose_keyed(
&self,
key: &[u8],
command: &M::Command,
) -> Result<M::Response, ClientError>
pub async fn propose_keyed( &self, key: &[u8], command: &M::Command, ) -> Result<M::Response, ClientError>
Propose a typed command to the Raft group that owns key.
§Errors
ClientError::Codec if the command cannot be encoded or the response
cannot be decoded, otherwise any error from the underlying KeyedClient.
Sourcepub async fn query_keyed(
&self,
key: &[u8],
query: &M::Query,
) -> Result<M::Response, ClientError>
pub async fn query_keyed( &self, key: &[u8], query: &M::Query, ) -> Result<M::Response, ClientError>
Run a typed linearizable query against the Raft group that owns key.
§Errors
ClientError::Codec if the query cannot be encoded or the response
cannot be decoded, otherwise any error from the underlying KeyedClient.