WASM: Add try_clone implementations to Request and RequestBuilder (#1286)

Currently the wasm client does not implement `try_clone` on `Request` or `RequestBuilder` like the blocking and async clients.

This PR adds infallible `try_clone` implementations to the wasm client to improve the API parity.

*Note*: Even though these APIs are infallible on wasm (no streaming bodies), I chose to keep the API identical.
This commit is contained in:
K.J. Valencik
2021-06-14 13:36:56 -04:00
committed by GitHub
parent b48cb4a5aa
commit c4388fcff9
2 changed files with 52 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ pub struct Body {
inner: Inner,
}
#[derive(Clone)]
enum Inner {
Bytes(Bytes),
#[cfg(feature = "multipart")]
@@ -56,6 +57,12 @@ impl Body {
Inner::Multipart(form) => form.is_empty(),
}
}
pub(crate) fn clone(&self) -> Body {
Self {
inner: self.inner.clone(),
}
}
}
impl From<Bytes> for Body {