aws_smithy_types/byte_stream/
http_body_1_x.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6//! Adapters to use http-body 1.0 bodies with SdkBody & ByteStream
7
8use crate::body::SdkBody;
9use crate::byte_stream::ByteStream;
10use bytes::Bytes;
11
12impl ByteStream {
13    /// Construct a `ByteStream` from a type that implements [`http_body_1_0::Body<Data = Bytes>`](http_body_1_0::Body).
14    ///
15    /// _Note: This is only available when the `http-body-1-x` feature is enabled._
16    pub fn from_body_1_x<T, E>(body: T) -> Self
17    where
18        T: http_body_1_0::Body<Data = Bytes, Error = E> + Send + Sync + 'static,
19        E: Into<crate::body::Error> + 'static,
20    {
21        ByteStream::new(SdkBody::from_body_1_x(body))
22    }
23}