wasm: add missing as_bytes method to Body implementation (#1270)
This commit is contained in:
@@ -24,6 +24,17 @@ enum Inner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
|
/// Returns a reference to the internal data of the `Body`.
|
||||||
|
///
|
||||||
|
/// `None` is returned, if the underlying data is a multipart form.
|
||||||
|
#[inline]
|
||||||
|
pub fn as_bytes(&self) -> Option<&[u8]> {
|
||||||
|
match &self.inner {
|
||||||
|
Inner::Bytes(bytes) => Some(bytes.as_ref()),
|
||||||
|
#[cfg(feature = "multipart")]
|
||||||
|
Inner::Multipart(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
pub(crate) fn to_js_value(&self) -> crate::Result<JsValue> {
|
pub(crate) fn to_js_value(&self) -> crate::Result<JsValue> {
|
||||||
match &self.inner {
|
match &self.inner {
|
||||||
Inner::Bytes(body_bytes) => {
|
Inner::Bytes(body_bytes) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user