Trait mz_service::client::GenericClient
source · pub trait GenericClient<C, R>: Debug + Send {
// Required methods
fn send<'life0, 'async_trait>(
&'life0 mut self,
cmd: C,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn as_stream<'a>(
&'a mut self,
) -> Pin<Box<dyn Stream<Item = Result<R, Error>> + Send + 'a>>
where R: Send + 'a { ... }
}
Expand description
A generic client to a server that receives commands and asynchronously produces responses.
Required Methods§
sourcefn send<'life0, 'async_trait>(
&'life0 mut self,
cmd: C,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 mut self,
cmd: C,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sends a command to the dataflow server.
The command can error for various reasons.
sourcefn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Receives the next response from the dataflow server.
This method blocks until the next response is available.
A return value of Ok(Some(_))
transmits a response.
A return value of Ok(None)
indicates graceful termination of the
connection. The owner of the client should not call recv
again.
A return value of Err(_)
indicates an unrecoverable error. After
observing an error, the owner of the client must drop the client.
Implementations of this method must be cancellation safe. That means that work must not be lost if the future returned by this method is dropped.
Provided Methods§
sourcefn as_stream<'a>(
&'a mut self,
) -> Pin<Box<dyn Stream<Item = Result<R, Error>> + Send + 'a>>where
R: Send + 'a,
fn as_stream<'a>(
&'a mut self,
) -> Pin<Box<dyn Stream<Item = Result<R, Error>> + Send + 'a>>where
R: Send + 'a,
Returns an adapter that treats the client as a stream.
The stream produces the responses that would be produced by repeated
calls to recv
.
§Cancel safety
The returned stream is cancel safe. If stream.next()
is used as the event in a
tokio::select!
statement and some other branch completes first, it is guaranteed that
no messages were received by this client.
Trait Implementations§
source§impl<C, R> GenericClient<C, R> for Box<dyn GenericClient<C, R>>where
C: Send,
impl<C, R> GenericClient<C, R> for Box<dyn GenericClient<C, R>>where
C: Send,
source§fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
§Cancel safety
This method is cancel safe. If recv
is used as the event in a tokio::select!
statement and some other branch completes first, it is guaranteed that no messages were
received by this client.
Implementations on Foreign Types§
source§impl<C, R> GenericClient<C, R> for Box<dyn GenericClient<C, R>>where
C: Send,
impl<C, R> GenericClient<C, R> for Box<dyn GenericClient<C, R>>where
C: Send,
source§fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<R>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
§Cancel safety
This method is cancel safe. If recv
is used as the event in a tokio::select!
statement and some other branch completes first, it is guaranteed that no messages were
received by this client.