pub trait RequestResponse {
    // Required methods
    fn req<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        msg: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn req_w_hint<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        msg: &'life1 str,
        hint: usize
    ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A trait representing a simple, textual request/response protocol like that employed by MPD: the caller sends a textual command & the server responds with a (perhaps multi-line) textual response.

This trait also enables unit testing client implementations. Note that it is async– cf. async_trait.

Required Methods§

source

fn req<'life0, 'life1, 'async_trait>( &'life0 mut self, msg: &'life1 str ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

source

fn req_w_hint<'life0, 'life1, 'async_trait>( &'life0 mut self, msg: &'life1 str, hint: usize ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The hint is used to size the buffer prior to reading the response

Implementors§

source§

impl<T> RequestResponse for MpdConnection<T>
where T: AsyncRead + AsyncWrite + Send + Unpin,

MpdConnection implements RequestResponse using the usual (async) socket I/O

The callers need not include the trailing newline in their requests; the implementation will append it.