diff options
author | Alex Auvolat <alex@adnab.me> | 2022-07-21 20:22:56 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-07-21 20:22:56 +0200 |
commit | 4934ed726d51913afd97ca937d0ece39ef8b7371 (patch) | |
tree | ad9560d819bfcbab9e35ee806bd9b2adaa8f9de5 /src/client.rs | |
parent | 7d148c7e764d563efa3bccc0f14f50867db38ef1 (diff) | |
download | netapp-4934ed726d51913afd97ca937d0ece39ef8b7371.tar.gz netapp-4934ed726d51913afd97ca937d0ece39ef8b7371.zip |
Propose alternative API
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/client.rs b/src/client.rs index 9d572aa..c878627 100644 --- a/src/client.rs +++ b/src/client.rs @@ -135,10 +135,10 @@ impl ClientConn { pub(crate) async fn call<T>( self: Arc<Self>, - rq: T, + req: Req<T>, path: &str, prio: RequestPriority, - ) -> Result<<T as Message>::Response, Error> + ) -> Result<Resp<T>, Error> where T: Message, { @@ -162,9 +162,8 @@ impl ClientConn { }; // Encode request - let (rq, stream) = rq.into_parts(); - let body = rmp_to_vec_all_named(&rq)?; - drop(rq); + let body = req.msg_ser.unwrap().clone(); + let stream = req.body.into_stream(); let request = QueryMessage { prio, @@ -216,7 +215,11 @@ impl ClientConn { let code = resp[0]; if code == 0 { let ser_resp = rmp_serde::decode::from_read_ref(&resp[1..])?; - Ok(T::Response::from_parts(ser_resp, stream)) + Ok(Resp { + _phantom: Default::default(), + msg: ser_resp, + body: BodyData::Stream(stream), + }) } else { let msg = String::from_utf8(resp[1..].to_vec()).unwrap_or_default(); Err(Error::Remote(code, msg)) |