Skip to main content

RawClient

Struct RawClient 

Source
pub struct RawClient {
    pub default_timeout: Duration,
    /* private fields */
}
Expand description

Async dispatcher around a single tokio I/O stream.

Fields§

§default_timeout: Duration

Default per-command deadline applied by RawClient::execute_command.

Implementations§

Source§

impl RawClient

Source

pub fn new<S>(stream: S) -> Self
where S: AsyncRead + AsyncWrite + Send + 'static,

Wrap an async stream, spawning the background read and write loops. The stream is split internally; commands are pipelined by tag.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

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.

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