pub struct RawClient {
pub default_timeout: Duration,
/* private fields */
}Expand description
Async dispatcher around a single tokio I/O stream.
Fields§
§default_timeout: DurationDefault per-command deadline applied by RawClient::execute_command.
Implementations§
Source§impl RawClient
impl RawClient
Sourcepub fn new<S>(stream: S) -> Self
pub fn new<S>(stream: S) -> Self
Wrap an async stream, spawning the background read and write loops. The stream is split internally; commands are pipelined by tag.
Sourcepub fn events(&self) -> Receiver<Vec<u8>>
pub fn events(&self) -> Receiver<Vec<u8>>
Subscribe to untagged server frames (data, status, and continuation
responses). Each subscriber gets its own receiver; slow consumers may
observe Lagged once they fall behind the channel capacity.
Sourcepub async fn execute_command(
&mut self,
cmd: &str,
) -> Result<Vec<u8>, ClientError>
pub async fn execute_command( &mut self, cmd: &str, ) -> Result<Vec<u8>, ClientError>
Send cmd as a tagged command, await the tagged status response.
On success returns the raw frame bytes (including the trailing CRLF).
On a NO/BAD tagged response returns
ClientError::CommandFailed containing the server’s resp-text.
Sourcepub async fn execute_command_with_timeout(
&mut self,
cmd: &str,
timeout: Duration,
) -> Result<Vec<u8>, ClientError>
pub async fn execute_command_with_timeout( &mut self, cmd: &str, timeout: Duration, ) -> Result<Vec<u8>, ClientError>
Like execute_command but with an explicit
timeout instead of default_timeout.
Sourcepub async fn send_command_async(
&mut self,
cmd: &str,
) -> Result<(String, Receiver<Result<Vec<u8>, ClientError>>), ClientError>
pub async fn send_command_async( &mut self, cmd: &str, ) -> Result<(String, Receiver<Result<Vec<u8>, ClientError>>), ClientError>
Send a command and return a receiver for its tagged response without awaiting. Used by long-running commands (e.g. IDLE) where the caller needs to interleave other I/O before the tagged reply arrives.
Sourcepub async fn send_raw(&mut self, bytes: Vec<u8>) -> Result<(), ClientError>
pub async fn send_raw(&mut self, bytes: Vec<u8>) -> Result<(), ClientError>
Send raw bytes on the wire. Used for IDLE’s DONE and other
continuation payloads where no new tag is allocated.
Sourcepub fn writer(&self) -> WriterHandle
pub fn writer(&self) -> WriterHandle
Cheap clone of the write side, suitable for handing to a long-lived
task (e.g. an IDLE handle) so it can send DONE without holding a
mutable borrow on the session.