feat(rust): add `to_vec()` for `RequestBuilder` and `ResponseBuilder`
@@ -359,6 +359,13 @@ impl<'a, T: Encode<()>> RequestBuilder<'a, T> {
}
Ok(())
}
+
+ pub fn to_vec(self) -> Result<Vec<u8>, encode::Error<<Vec<u8> as Write>::Error>> {
+ let mut buf = Vec::new();
+ self.encode(&mut buf)?;
+
+ Ok(buf)
+ }
}
#[derive(Debug)]
@@ -415,6 +422,13 @@ impl<T: Encode<()>> ResponseBuilder<T> {
}
Ok(())
}
+
+ pub fn to_vec(self) -> Result<Vec<u8>, encode::Error<<Vec<u8> as Write>::Error>> {
+ let mut buf = Vec::new();
+ self.encode(&mut buf)?;
+
+ Ok(buf)
+ }
}
/// A newtype around `Cow<'_, str>` that borrows from input.
