aws_smithy_types::body

Struct SdkBody

Source
pub struct SdkBody { /* private fields */ }
Expand description

SdkBody type

This is the Body used for dispatching all HTTP Requests. For handling responses, the type of the body will be controlled by the HTTP stack.

Implementations§

Source§

impl SdkBody

Source

pub fn from_body_0_4<T, E>(body: T) -> Self
where T: Body<Data = Bytes, Error = E> + Send + Sync + 'static, E: Into<Error> + 'static,

Construct an SdkBody from a type that implements http_body_0_4::Body<Data = Bytes>.

Note: This is only available with http-body-0-4-x enabled.

Source§

impl SdkBody

Source

pub fn from_body_1_x<T, E>(body: T) -> Self
where T: Body<Data = Bytes, Error = E> + Send + Sync + 'static, E: Into<Error> + 'static,

Construct an SdkBody from a type that implements http_body_1_0::Body<Data = Bytes>.

Source§

impl SdkBody

Source

pub fn retryable(f: impl Fn() -> SdkBody + Send + Sync + 'static) -> Self

Construct an explicitly retryable SDK body

Note: This is probably not what you want

All bodies constructed from in-memory data (String, Vec<u8>, Bytes, etc.) will be retryable out of the box. If you want to read data from a file, you should use ByteStream::from_path. This function is only necessary when you need to enable retries for your own streaming container.

Source

pub fn taken() -> Self

When an SdkBody is read, the inner data must be consumed. In order to do this, the SdkBody is swapped with a “taken” body. This “taken” body cannot be read but aids in debugging.

Source

pub fn empty() -> Self

Create an empty SdkBody for requests and responses that don’t transfer any data in the body.

Source

pub fn bytes(&self) -> Option<&[u8]>

If possible, return a reference to this body as &[u8]

If this SdkBody is NOT streaming, this will return the byte slab If this SdkBody is streaming, this will return None

Source

pub fn try_clone(&self) -> Option<Self>

Attempt to clone this SdkBody. This will fail if the inner data is not cloneable, such as when it is a single-use stream that can’t be recreated.

Source

pub fn is_streaming(&self) -> bool

Return true if this SdkBody is streaming, false if it is in-memory.

Source

pub fn content_length(&self) -> Option<u64>

Return the length, in bytes, of this SdkBody. If this returns None, then the body does not have a known length.

Source

pub fn map( self, f: impl Fn(SdkBody) -> SdkBody + Sync + Send + 'static, ) -> SdkBody

Given a function to modify an SdkBody, run that function against this SdkBody before returning the result.

Source

pub fn map_preserve_contents( self, f: impl Fn(SdkBody) -> SdkBody + Sync + Send + 'static, ) -> SdkBody

Update this SdkBody with map. This function MUST NOT alter the data of the body.

This function is useful for adding metadata like progress tracking to an SdkBody that does not alter the actual byte data. If your mapper alters the contents of the body, use SdkBody::map instead.

Trait Implementations§

Source§

impl Body for SdkBody

Source§

type Data = Bytes

Values yielded by the Body.
Source§

type Error = Box<dyn Error + Send + Sync>

The error type this Body might generate.
Source§

fn poll_data( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Self::Data, Self::Error>>>

Attempt to pull out the next data buffer of this stream.
Source§

fn poll_trailers( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<Option<HeaderMap<HeaderValue>>, Self::Error>>

Poll for an optional single HeaderMap of trailers. Read more
Source§

fn is_end_stream(&self) -> bool

Returns true when the end of stream has been reached. Read more
Source§

fn size_hint(&self) -> SizeHint

Returns the bounds on the remaining length of the stream. Read more
Source§

fn data(&mut self) -> Data<'_, Self>
where Self: Sized + Unpin,

Returns future that resolves to next data chunk, if any.
Source§

fn trailers(&mut self) -> Trailers<'_, Self>
where Self: Sized + Unpin,

Returns future that resolves to trailers, if any.
Source§

fn map_data<F, B>(self, f: F) -> MapData<Self, F>
where Self: Sized, F: FnMut(Self::Data) -> B, B: Buf,

Maps this body’s data value to a different value.
Source§

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnMut(Self::Error) -> E,

Maps this body’s error value to a different value.
Source§

fn collect(self) -> Collect<Self>
where Self: Sized,

Turn this body into Collected body which will collect all the DATA frames and trailers.
Source§

fn boxed(self) -> BoxBody<Self::Data, Self::Error>
where Self: Sized + Send + Sync + 'static,

Turn this body into a boxed trait object.
Source§

fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
where Self: Sized + Send + 'static,

Turn this body into a boxed trait object that is !Sync.
Source§

impl Body for SdkBody

Source§

type Data = Bytes

Values yielded by the Body.
Source§

type Error = Box<dyn Error + Send + Sync>

The error type this Body might generate.
Source§

fn poll_frame( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>>

Attempt to pull out the next data buffer of this stream.
Source§

fn is_end_stream(&self) -> bool

Returns true when the end of stream has been reached. Read more
Source§

fn size_hint(&self) -> SizeHint

Returns the bounds on the remaining length of the stream. Read more
Source§

impl Debug for SdkBody

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&[u8]> for SdkBody

Source§

fn from(data: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for SdkBody

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Bytes> for SdkBody

Source§

fn from(bytes: Bytes) -> Self

Converts to this type from the input type.
Source§

impl From<SdkBody> for ByteStream

Source§

fn from(inp: SdkBody) -> Self

Converts to this type from the input type.
Source§

impl From<String> for SdkBody

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for SdkBody

Source§

fn from(data: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl<'__pin> Unpin for SdkBody
where PinnedFieldsOf<__Origin<'__pin>>: Unpin,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> BodyExt for T
where T: Body + ?Sized,

Source§

fn frame(&mut self) -> Frame<'_, Self>
where Self: Unpin,

Returns a future that resolves to the next Frame, if any.
Source§

fn map_frame<F, B>(self, f: F) -> MapFrame<Self, F>
where Self: Sized, F: FnMut(Frame<Self::Data>) -> Frame<B>, B: Buf,

Maps this body’s frame to a different kind.
Source§

fn map_err<F, E>(self, f: F) -> MapErr<Self, F>
where Self: Sized, F: FnMut(Self::Error) -> E,

Maps this body’s error value to a different value.
Source§

fn boxed(self) -> BoxBody<Self::Data, Self::Error>
where Self: Sized + Send + Sync + 'static,

Turn this body into a boxed trait object.
Source§

fn boxed_unsync(self) -> UnsyncBoxBody<Self::Data, Self::Error>
where Self: Sized + Send + 'static,

Turn this body into a boxed trait object that is !Sync.
Source§

fn collect(self) -> Collect<Self>
where Self: Sized,

Turn this body into Collected body which will collect all the DATA frames and trailers.
Source§

fn with_trailers<F>(self, trailers: F) -> WithTrailers<Self, F>
where Self: Sized, F: Future<Output = Option<Result<HeaderMap, Self::Error>>>,

Add trailers to the body. Read more
Source§

fn into_data_stream(self) -> BodyDataStream<Self>
where Self: Sized,

Turn this body into BodyDataStream.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.