pub struct RequestBody(/* private fields */);Expand description
A request body on the schema-routing pipeline.
A request entering through hyper keeps its Incoming body
inside the Hyper state, without boxing. The routing service replaces it with the
Buffered state after collecting for a body-first protocol. Other compatible HTTP bodies
enter through RequestBody::new, which erases them into a boxed state.
RequestBody::prefixed replays bytes already read ahead of the remaining body. This allows
middleware to inspect a prefix, then forward the full request without collecting the rest.
The states are private so buffering and transport-specific optimizations can evolve.
RequestBody is Send and Sync, so it can be handed to SdkBody::from_body_1_x
when an operation input has a streaming member; SdkBody only accepts Sync bodies.
Implementations§
Source§impl RequestBody
impl RequestBody
Sourcepub fn new<T>(body: T) -> Self
pub fn new<T>(body: T) -> Self
Wraps any compatible HTTP body without polling it.
A hyper incoming body and an already-wrapped RequestBody stay unerased; any other
body type is erased into a boxed state.
Sourcepub fn prefixed(prefix: Bytes, trailers: Option<HeaderMap>, tail: Self) -> Self
pub fn prefixed(prefix: Bytes, trailers: Option<HeaderMap>, tail: Self) -> Self
Replays bytes already read from a request ahead of its remaining body.
Include all consumed data in prefix so downstream readers receive the full request.
Construction does not poll or erase tail. An empty prefix with no captured trailers
returns tail unchanged.
Pass None for trailers when only data has been read: unread trailers arrive from
tail normally. If trailer frames were already read, pass them here to replay them
after tail reaches end-of-stream.
Sourcepub fn from_bytes(bytes: Bytes) -> Self
pub fn from_bytes(bytes: Bytes) -> Self
Creates a request body containing buffered bytes.
Trait Implementations§
Source§impl Body for RequestBody
impl Body for RequestBody
Source§impl Debug for RequestBody
impl Debug for RequestBody
Source§impl Default for RequestBody
impl Default for RequestBody
Source§impl From<&'static [u8]> for RequestBody
impl From<&'static [u8]> for RequestBody
Source§impl From<&'static str> for RequestBody
impl From<&'static str> for RequestBody
Source§impl From<Bytes> for RequestBody
impl From<Bytes> for RequestBody
Source§impl From<String> for RequestBody
impl From<String> for RequestBody
Auto Trait Implementations§
impl !Freeze for RequestBody
impl !RefUnwindSafe for RequestBody
impl Send for RequestBody
impl Sync for RequestBody
impl Unpin for RequestBody
impl UnsafeUnpin for RequestBody
impl !UnwindSafe for RequestBody
Blanket Implementations§
§impl<T> BodyExt for T
impl<T> BodyExt for T
§fn frame(&mut self) -> Frame<'_, Self>where
Self: Unpin,
fn frame(&mut self) -> Frame<'_, Self>where
Self: Unpin,
Frame, if any.§fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
fn inspect_frame<F>(self, f: F) -> InspectFrame<Self, F>
§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
§fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
Collected] body which will collect all the DATA frames
and trailers.§fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
§fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
fn into_stream(self) -> BodyStream<Self>where
Self: Sized,
BodyStream].§fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
fn into_data_stream(self) -> BodyDataStream<Self>where
Self: Sized,
BodyDataStream].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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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