pub struct JsBody(/* private fields */);Expand description
Zero-copy body wrapper. Holds the raw ReadableStream from the incoming
request, passing it through the Gateway untouched for Forward requests.
Implementations§
Source§impl JsBody
impl JsBody
Sourcepub fn new(stream: Option<ReadableStream>) -> Self
pub fn new(stream: Option<ReadableStream>) -> Self
Wrap an optional ReadableStream from a web_sys::Request.
Sourcepub fn stream(&self) -> Option<&ReadableStream>
pub fn stream(&self) -> Option<&ReadableStream>
Borrow the inner stream, if present.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, String>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, String>
Build a JsBody whose stream yields the given bytes.
Used to hand an equivalent body back after collecting one (e.g.
RequestParts::absorb_form_body),
so a request that falls through to the forwarding path still carries
its payload. Uses the same web_sys::Response trick as
collect_js_body, in reverse.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JsBody
impl RefUnwindSafe for JsBody
impl Unpin for JsBody
impl UnsafeUnpin for JsBody
impl UnwindSafe for JsBody
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more