Trait mpdpopm::clients::RequestResponse
source · 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§
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,
sourcefn 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,
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§
impl<T> RequestResponse for MpdConnection<T>
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.