aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-07-22 13:40:06 +0200
committerAlex Auvolat <alex@adnab.me>2022-07-22 13:40:06 +0200
commit67ea3a48fa1c9c462f1c4912c9658ad002d3336d (patch)
tree0ffcc7e4eb020246df0271b16dff2720ea6f483a /src
parentb9df442f035e6648e80adf8f9bf86b4943508ae5 (diff)
downloadnetapp-67ea3a48fa1c9c462f1c4912c9658ad002d3336d.tar.gz
netapp-67ea3a48fa1c9c462f1c4912c9658ad002d3336d.zip
Add Resp::into_parts
Diffstat (limited to 'src')
-rw-r--r--src/message.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/message.rs b/src/message.rs
index 0ac4cb8..8e4bc2f 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -63,10 +63,6 @@ pub struct Req<M: Message> {
}
impl<M: Message> Req<M> {
- pub fn msg(&self) -> &M {
- &self.msg
- }
-
pub fn with_fixed_body(self, b: Bytes) -> Self {
Self {
body: BodyData::Fixed(b),
@@ -81,6 +77,10 @@ impl<M: Message> Req<M> {
}
}
+ pub fn msg(&self) -> &M {
+ &self.msg
+ }
+
pub fn take_stream(&mut self) -> Option<ByteStream> {
std::mem::replace(&mut self.body, BodyData::None).into_stream()
}
@@ -216,6 +216,10 @@ impl<M: Message> Resp<M> {
self.msg
}
+ pub fn into_parts(self) -> (M::Response, Option<ByteStream>) {
+ (self.msg, self.body.into_stream())
+ }
+
pub(crate) fn into_enc(self) -> Result<RespEnc, rmp_serde::encode::Error> {
Ok(RespEnc::Success {
msg: rmp_to_vec_all_named(&self.msg)?.into(),