id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
/// .path("docs/some-large-file.csv") /// // Specify the size of the buffer used to read the file (in bytes, default is 4096) /// .buffer_size(32_784) /// // Specify the length of the file used (skips an additional call to retrieve the size) /// .length(Length::Ex...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
/// } /// ``` #[cfg(feature = "rt-tokio")] #[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))] pub async fn from_path(path: impl AsRef<std::path::Path>) -> Result<Self, Error> { FsBuilder::new().path(path).build().await } /// Create a ByteStream from a file /// /// NOTE: This wi...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
fn from(inp: SdkBody) -> Self { ByteStream::new(inp) } } /// Construct a retryable ByteStream from [`bytes::Bytes`](bytes::Bytes) impl From<Bytes> for ByteStream { fn from(input: Bytes) -> Self { ByteStream::new(SdkBody::from(input)) } } /// Construct a retryable ByteStream from a `Vec<u8>...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
fn source(&self) -> Option<&(dyn StdError + 'static)> { Some(self.0.as_ref() as _) } } impl futures_core::stream::Stream for ByteStream { type Item = Result<Bytes, Error>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { self.project().0.poll_next(cx)....
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
impl Buf for AggregatedBytes { // Forward all methods that SegmentedBuf has custom implementations of. fn remaining(&self) -> usize { self.0.remaining() } fn chunk(&self) -> &[u8] { self.0.chunk() } fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize { se...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
let mut output = SegmentedBuf::new(); let body = self.body; crate::pin_mut!(body); while let Some(buf) = body.data().await { output.push(buf?); } Ok(AggregatedBytes(output)) } } impl Inner<SdkBody> { fn with_body_callback(&mut self, body_callback: Box<dyn Bod...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:14
size_hint.upper().map(|u| u as usize), ) } } #[cfg(test)] mod tests { use crate::byte_stream::Inner; use bytes::Bytes; #[tokio::test] async fn read_from_string_body() { let body = hyper::Body::from("a simple body"); assert_eq!( Inner::new(body) ....
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:15
async fn path_based_bytestreams() -> Result<(), Box<dyn std::error::Error>> { use super::ByteStream; use bytes::Buf; use http_body::Body; use std::io::Write; use tempfile::NamedTempFile; let mut file = NamedTempFile::new()?; for i in 0..10000 { writel...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream.rs
561
600
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:3
//! ```no_run //! # #[cfg(feature = "rt-tokio")] //! # { //! use aws_smithy_http::byte_stream::ByteStream; //! use std::path::Path; //! struct GetObjectInput { //! body: ByteStream //! } //! //! async fn bytestream_from_file() -> GetObjectInput { //! let bytestream = ByteStream::from_path("docs/some-large-file.cs...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
81
140
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:4
//! ``` use crate::body::SdkBody; use crate::callback::BodyCallback; use bytes::Buf; use bytes::Bytes; use bytes_utils::SegmentedBuf; use http_body::Body; use pin_project::pin_project; use std::error::Error as StdError; use std::fmt::{Debug, Formatter}; use std::io::IoSlice; use std::pin::Pin; use std::task::{Context,...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
121
180
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
/// .buffer_size(32_784) /// // Specify the length of the file used (skips an additional call to retrieve the size) /// .file_size(123_456) /// .build() /// .await /// .expect("valid path"); /// bytestream /// } /// # } /// ``` ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
#[cfg(feature = "rt-tokio")] #[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))] pub async fn from_path(path: impl AsRef<std::path::Path>) -> Result<Self, Error> { FsBuilder::new().path(path).build().await } /// Create a ByteStream from a file /// /// NOTE: This will NOT result in a ret...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
} } /// Construct a retryable ByteStream from [`bytes::Bytes`](bytes::Bytes) impl From<Bytes> for ByteStream { fn from(input: Bytes) -> Self { ByteStream::new(SdkBody::from(input)) } } /// Construct a retryable ByteStream from a `Vec<u8>`. /// /// This will convert the `Vec<u8>` into [`bytes::Bytes`](...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
} } impl futures_core::stream::Stream for ByteStream { type Item = Result<Bytes, Error>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { self.project().0.poll_next(cx).map_err(|e| Error(e)) } fn size_hint(&self) -> (usize, Option<usize>) { self.0...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
// Forward all methods that SegmentedBuf has custom implementations of. fn remaining(&self) -> usize { self.0.remaining() } fn chunk(&self) -> &[u8] { self.0.chunk() } fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize { self.0.chunks_vectored(dst) } ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
crate::pin_mut!(body); while let Some(buf) = body.data().await { output.push(buf?); } Ok(AggregatedBytes(output)) } } impl Inner<SdkBody> { fn with_body_callback(&mut self, body_callback: Box<dyn BodyCallback>) -> &mut Self { self.body.with_callback(body_callback); ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:14
} } #[cfg(test)] mod tests { use crate::byte_stream::Inner; use bytes::Bytes; #[tokio::test] async fn read_from_string_body() { let body = hyper::Body::from("a simple body"); assert_eq!( Inner::new(body) .collect() .await .exp...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:15
use bytes::Buf; use http_body::Body; use std::io::Write; use tempfile::NamedTempFile; let mut file = NamedTempFile::new()?; for i in 0..10000 { writeln!(file, "Brian was here. Briefly. {}", i)?; } let body = ByteStream::from_path(&file).await?.into_in...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
561
620
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:16
async fn path_based_bytestreams_with_builder() -> Result<(), Box<dyn std::error::Error>> { use super::ByteStream; use bytes::Buf; use http_body::Body; use std::io::Write; use tempfile::NamedTempFile; let mut file = NamedTempFile::new()?; for i in 0..10000 { ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
8159cb8ff570e4dca718e354c31cecdfadfeb0b8
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/8159cb8ff570e4dca718e354c31cecdfadfeb0b8/sdk/aws-smithy-http/src/byte_stream.rs
601
641
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:3
//! ```no_run //! # #[cfg(feature = "rt-tokio")] //! # { //! use aws_smithy_http::byte_stream::ByteStream; //! use std::path::Path; //! struct GetObjectInput { //! body: ByteStream //! } //! //! async fn bytestream_from_file() -> GetObjectInput { //! let bytestream = ByteStream::from_path("docs/some-large-file.cs...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
81
140
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:4
//! ``` use crate::body::SdkBody; use bytes::Buf; use bytes::Bytes; use bytes_utils::SegmentedBuf; use http_body::Body; use pin_project::pin_project; use std::error::Error as StdError; use std::fmt::{Debug, Formatter}; use std::io::IoSlice; use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(feature = "rt-tokio"...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
121
180
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
/// // Specify the length of the file used (skips an additional call to retrieve the size) /// .file_size(123_456) /// .build() /// .await /// .expect("valid path"); /// bytestream /// } /// # } /// ``` #[cfg(feature = "rt-tokio")] #[cf...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
#[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))] pub async fn from_path(path: impl AsRef<std::path::Path>) -> Result<Self, Error> { FsBuilder::new().path(path).build().await } /// Create a ByteStream from a file /// /// NOTE: This will NOT result in a retryable ByteStream. For a ByteStre...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
/// Construct a retryable ByteStream from a `Vec<u8>`. /// /// This will convert the `Vec<u8>` into [`bytes::Bytes`](bytes::Bytes) to enable efficient /// retries. impl From<Vec<u8>> for ByteStream { fn from(input: Vec<u8>) -> Self { Self::from(Bytes::from(input)) } } impl From<hyper::Body> for ByteStr...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
fn size_hint(&self) -> (usize, Option<usize>) { self.0.size_hint() } } /// Non-contiguous Binary Data Storage /// /// When data is read from the network, it is read in a sequence of chunks that are not in /// contiguous memory. [`AggregatedBytes`](crate::byte_stream::AggregatedBytes) provides a view of ///...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
fn chunks_vectored<'a>(&'a self, dst: &mut [IoSlice<'a>]) -> usize { self.0.chunks_vectored(dst) } fn advance(&mut self, cnt: usize) { self.0.advance(cnt) } fn copy_to_bytes(&mut self, len: usize) -> Bytes { self.0.copy_to_bytes(len) } } #[pin_project] #[derive(Debug, Clon...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
B: http_body::Body, { type Item = Result<Bytes, B::Error>; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { match self.project().body.poll_data(cx) { Poll::Ready(Some(Ok(mut data))) => { let len = data.chunk().len(); let ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:14
Bytes::from("a simple body") ); } #[tokio::test] async fn read_from_channel_body() { let (mut sender, body) = hyper::Body::channel(); let byte_stream = Inner::new(body); tokio::spawn(async move { sender.send_data(Bytes::from("data 1")).await.unwrap(); ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:15
.expect("should have some data") .expect("read should not fail"); assert!(!some_data.is_empty()); // make some more clones let body2 = body.try_clone().expect("retryable bodies are cloneable"); let body3 = body.try_clone().expect("retryable bodies are cloneable"); let...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
561
620
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:16
.await? .into_inner(); // assert that the file length specified size is used as size hint assert_eq!(body.size_hint().exact(), Some(200)); let mut body1 = body.try_clone().expect("retryable bodies are cloneable"); // read a little bit from one of the clones let some...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
05c13b4a734cb2f7c2592e8e395ccf8647c9f077
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/05c13b4a734cb2f7c2592e8e395ccf8647c9f077/sdk/aws-smithy-http/src/byte_stream.rs
601
624
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:6
#[pin_project] #[derive(Debug)] pub struct ByteStream(#[pin] Inner<SdkBody>); impl ByteStream { pub fn new(body: SdkBody) -> Self { Self(Inner::new(body)) } pub fn from_static(bytes: &'static [u8]) -> Self { Self(Inner::new(SdkBody::from(Bytes::from_static(bytes)))) } /// Consumes...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
201
260
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:7
/// Create a ByteStream that streams data from the filesystem /// /// This function creates a retryable ByteStream for a given `path`. The returned ByteStream /// will provide a size hint when used as an HTTP body. If the request fails, the read will /// begin again by reloading the file handle. ///...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
241
300
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
/// NOTE: This will NOT result in a retryable ByteStream. For a ByteStream that can be retried in the case of /// upstream failures, use [`ByteStream::from_path`](ByteStream::from_path) #[cfg(feature = "rt-tokio")] #[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))] pub async fn from_file(file: tokio::f...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
/// This will convert the `Vec<u8>` into [`bytes::Bytes`](bytes::Bytes) to enable efficient /// retries. impl From<Vec<u8>> for ByteStream { fn from(input: Vec<u8>) -> Self { Self::from(Bytes::from(input)) } } impl From<hyper::Body> for ByteStream { fn from(input: hyper::Body) -> Self { Byt...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
} } /// Non-contiguous Binary Data Storage /// /// When data is read from the network, it is read in a sequence of chunks that are not in /// contiguous memory. [`AggregatedBytes`](crate::byte_stream::AggregatedBytes) provides a view of /// this data via [`impl Buf`](bytes::Buf) or it can be copied into contiguous sto...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
fn advance(&mut self, cnt: usize) { self.0.advance(cnt) } fn copy_to_bytes(&mut self, len: usize) -> Bytes { self.0.copy_to_bytes(len) } } #[pin_project] #[derive(Debug, Clone, PartialEq, Eq)] struct Inner<B> { #[pin] body: B, } impl<B> Inner<B> { pub fn new(body: B) -> Self {...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { match self.project().body.poll_data(cx) { Poll::Ready(Some(Ok(mut data))) => { let len = data.chunk().len(); let bytes = data.copy_to_bytes(len); Poll::Ready(Some(Ok...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
#[tokio::test] async fn read_from_channel_body() { let (mut sender, body) = hyper::Body::channel(); let byte_stream = Inner::new(body); tokio::spawn(async move { sender.send_data(Bytes::from("data 1")).await.unwrap(); sender.send_data(Bytes::from("data 2")).await.unwr...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
481
538
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:14
// make some more clones let body2 = body.try_clone().expect("retryable bodies are cloneable"); let body3 = body.try_clone().expect("retryable bodies are cloneable"); let body2 = ByteStream::new(body2).collect().await?.into_bytes(); let body3 = ByteStream::new(body3).collect().await?.int...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
6ef6857803f55a084ed6d8348dac01371d7102a1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/6ef6857803f55a084ed6d8348dac01371d7102a1/sdk/aws-smithy-http/src/byte_stream.rs
521
538
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
/// NOTE: This will NOT result in a retryable ByteStream. For a ByteStream that can be retried in the case of /// upstream failures, use [`ByteStream::from_path`](ByteStream::from_path) #[cfg(feature = "rt-tokio")] #[cfg_attr(docsrs, doc(cfg(feature = "rt-tokio")))] pub async fn from_file(file: tokio::f...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
/// This will convert the `Vec<u8>` into [`bytes::Bytes`](bytes::Bytes) to enable efficient /// retries. impl From<Vec<u8>> for ByteStream { fn from(input: Vec<u8>) -> Self { Self::from(Bytes::from(input)) } } #[derive(Debug)] pub struct Error(Box<dyn StdError + Send + Sync + 'static>); impl std::fmt:...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
/// [`.into_bytes()`](crate::byte_stream::AggregatedBytes::into_bytes). #[derive(Debug, Clone)] pub struct AggregatedBytes(SegmentedBuf<Bytes>); impl AggregatedBytes { /// Convert this buffer into [`Bytes`](bytes::Bytes) /// /// # Why does this consume `self`? /// Technically, [`copy_to_bytes`](bytes::...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
} #[pin_project] #[derive(Debug, Clone, PartialEq, Eq)] struct Inner<B> { #[pin] body: B, } impl<B> Inner<B> { pub fn new(body: B) -> Self { Self { body } } pub async fn collect(self) -> Result<AggregatedBytes, B::Error> where B: http_body::Body<Data = Bytes>, { let...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
Poll::Ready(None) => Poll::Ready(None), Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))), Poll::Pending => Poll::Pending, } } fn size_hint(&self) -> (usize, Option<usize>) { let size_hint = http_body::Body::size_hint(&self.body); ( size_hint.low...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
sender.send_data(Bytes::from("data 3")).await.unwrap(); }); assert_eq!( byte_stream.collect().await.expect("no errors").into_bytes(), Bytes::from("data 1data 2data 3") ); } #[cfg(feature = "rt-tokio")] #[tokio::test] async fn path_based_bytestreams() -> R...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
481
530
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:14
assert_eq!(body2.len(), 298890); assert_eq!( ByteStream::new(body1).collect().await?.remaining(), 298890 - some_data.len() ); Ok(()) } }
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
3d3e1225e59755683893b72ab74bb68a5a853c8d
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/3d3e1225e59755683893b72ab74bb68a5a853c8d/sdk/aws-smithy-http/src/byte_stream.rs
521
530
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:6
pub fn from_static(bytes: &'static [u8]) -> Self { Self(Inner::new(SdkBody::from(Bytes::from_static(bytes)))) } /// Consumes the ByteStream, returning the wrapped SdkBody // Backwards compatibility note: Because SdkBody has a dyn variant, // we will always be able to implement this method, even...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
201
260
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:7
/// The contents of the file MUST not change during retries. The length & checksum of the file /// will be cached. If the contents of the file change, the operation will almost certainly fail. /// /// Furthermore, a partial write MAY seek in the file and resume from the previous location. /// /// # ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
241
300
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:8
.map_err(|err| Error(err.into()))? .len(); let body = SdkBody::from_dyn(http_body::combinators::BoxBody::new( bytestream_util::PathBody::from_file(file, sz), )); Ok(ByteStream::new(body)) } } impl Default for ByteStream { fn default() -> Self { Self(Inner...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:9
#[derive(Debug)] pub struct Error(Box<dyn StdError + Send + Sync + 'static>); impl std::fmt::Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } impl StdError for Error { fn source(&self) -> Option<&(dyn StdError + 'static)> { Some(sel...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:10
/// Technically, [`copy_to_bytes`](bytes::Buf::copy_to_bytes) can be called without ownership of self. However, since this /// mutates the underlying buffer such that no data is remaining, it is more misuse resistant to /// prevent the caller from attempting to reread the buffer. /// /// If the caller o...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:11
impl<B> Inner<B> { pub fn new(body: B) -> Self { Self { body } } pub async fn collect(self) -> Result<AggregatedBytes, B::Error> where B: http_body::Body<Data = Bytes>, { let mut output = SegmentedBuf::new(); let body = self.body; crate::pin_mut!(body); ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:12
( size_hint.lower() as usize, size_hint.upper().map(|u| u as usize), ) } } #[cfg(test)] mod tests { use crate::byte_stream::{ByteStream, Inner}; use bytes::{Buf, Bytes}; use http_body::Body; use std::error::Error; #[tokio::test] async fn read_from_string_bod...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream.rs:13
} #[cfg(feature = "rt-tokio")] #[tokio::test] async fn path_based_bytestreams() -> Result<(), Box<dyn Error>> { use std::io::Write; use tempfile::NamedTempFile; let mut file = NamedTempFile::new()?; for i in 0..10000 { writeln!(file, "Brian was here. Briefly. {}...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream.rs
Apache-2.0
fe1cfc31a925306b740e22a005fbf0ab6ec4fca7
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/fe1cfc31a925306b740e22a005fbf0ab6ec4fca7/sdk/aws-smithy-http/src/byte_stream.rs
481
521
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:1
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ use crate::body::SdkBody; use crate::byte_stream::{error::Error, error::ErrorKind, ByteStream}; use bytes::Bytes; use futures_core::ready; use http::HeaderMap; use http_body::{Body, SizeHint}; use std::f...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
1
60
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:2
fn from_path(path_buf: PathBuf, length: u64, buffer_size: usize, offset: Option<u64>) -> Self { PathBody { state: State::Unloaded(path_buf), length, buffer_size, offset, } } fn from_file(file: File, length: u64, buffer_size: usize) -> Self { ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
41
100
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:3
/// .await /// .expect("valid path"); /// GetObjectInput { body: bytestream } /// } /// # } /// ``` #[allow(missing_debug_implementations)] pub struct FsBuilder { file: Option<File>, path: Option<PathBuf>, length: Option<Length>, buffer_size: usize, offset: Option<u64>, } impl D...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
81
140
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:4
offset: None, path: None, } } /// Sets the path to read from. /// /// NOTE: The resulting ByteStream (after calling [build](FsBuilder::build)) will be retryable. /// The returned ByteStream will provide a size hint when used as an HTTP body. /// If the request fails, the rea...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
121
180
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:5
self } /// Specify the offset to start reading from (in bytes) /// /// When used in conjunction with [`length`](FsBuilder::length), allows for reading a single "chunk" of a file. pub fn offset(mut self, offset: u64) -> Self { self.offset = Some(offset); self } /// Returns a...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
161
220
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:6
// time the file is loaded. SdkBody::from_dyn(http_body::combinators::BoxBody::new(PathBody::from_path( path.clone(), length, buffer_size, self.offset, ))) }; Ok(ByteStream::new(SdkBo...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
201
260
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:7
} impl Body for PathBody { type Data = Bytes; type Error = Box<dyn std::error::Error + Send + Sync + 'static>; fn poll_data( mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Self::Data, Self::Error>>> { let offset = self.offset.unwrap_or(DEFAULT_OFFSET); ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
241
300
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:8
None => Poll::Ready(None), Some(Err(e)) => Poll::Ready(Some(Err(e.into()))), }; } }; } } fn poll_trailers( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<Option<HeaderMap>, Self::Error>> { ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:9
} let file_length = file .as_file() .metadata() .expect("file metadata is accessible") .len(); let body = FsBuilder::new() .path(&file) .buffer_size(16384) .length(Length::Exact(file_length)) .build() ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:10
"A very long sentence that's clearly longer than a single byte." ) .unwrap(); // Ensure that the file was written to file.flush().expect("flushing is OK"); let body = FsBuilder::new() .path(&file) // The file is longer than 1 byte, let's see if this is us...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:11
assert_eq!(&data_str, line_0); } #[tokio::test] async fn fsbuilder_length_exact() { let mut file = NamedTempFile::new().unwrap(); let test_sentence = "This sentence is 30 bytes long"; assert_eq!(test_sentence.len(), 30); write!(file, "{}", test_sentence).unwrap(); /...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:12
async fn fsbuilder_supports_offset() { let mut file = NamedTempFile::new().unwrap(); let line_0 = "Line 0\n"; let line_1 = "Line 1\n"; write!(file, "{}", line_0).unwrap(); write!(file, "{}", line_1).unwrap(); // Ensure that the file was written to file.flush().e...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:13
.path(&file) // We're going to skip line 0 by using offset .offset(line_0.len() as u64) // We want to read only line 1 and stop before we get to line 2 .length(Length::Exact(line_1.len() as u64)) .build() .await .unwrap(); let ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:14
#[tokio::test] async fn fsbuilder_with_length_greater_than_file_length_reads_everything() { let mut file = NamedTempFile::new().unwrap(); let line_0 = "Line 0\n"; let line_1 = "Line 1\n"; write!(file, "{}", line_0).unwrap(); write!(file, "{}", line_1).unwrap(); // E...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:15
for i in 0..1000 { writeln!(in_memory_copy_of_file_contents, "Line {:04}", i).unwrap(); } // Check we wrote the lines assert!(!in_memory_copy_of_file_contents.is_empty()); } let file_size = file.as_file().metadata().unwrap().len(); // Check th...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
2b4a7b881b8735aad288284e1c140ed40f474d06
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/2b4a7b881b8735aad288284e1c140ed40f474d06/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
561
609
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:2
fn from_path(path_buf: PathBuf, length: u64, buffer_size: usize, offset: Option<u64>) -> Self { PathBody { state: State::Unloaded(path_buf), length, buffer_size, offset, } } fn from_file(file: File, length: u64, buffer_size: usize) -> Self { ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
41
100
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:3
/// .await /// .expect("valid path"); /// GetObjectInput { body: bytestream } /// } /// # } /// ``` pub struct FsBuilder { file: Option<tokio::fs::File>, path: Option<PathBuf>, length: Option<Length>, buffer_size: usize, offset: Option<u64>, } impl Default for FsBuilder { fn...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
81
140
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:4
} } /// Sets the path to read from. /// /// NOTE: The resulting ByteStream (after calling [build](FsBuilder::build)) will be retryable. /// The returned ByteStream will provide a size hint when used as an HTTP body. /// If the request fails, the read will begin again by reloading the file handl...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
121
180
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:5
/// Specify the offset to start reading from (in bytes) /// /// When used in conjunction with [`length`](FsBuilder::length), allows for reading a single "chunk" of a file. pub fn offset(mut self, offset: u64) -> Self { self.offset = Some(offset); self } /// Returns a [`ByteStream`](...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
161
220
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:6
path.clone(), length, buffer_size, self.offset, ))) }; Ok(ByteStream::new(SdkBody::retryable(body_loader))) } else if let Some(mut file) = self.file { // When starting from a `File`, we need to do ou...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
201
260
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:7
impl Body for PathBody { type Data = Bytes; type Error = Box<dyn std::error::Error + Send + Sync + 'static>; fn poll_data( mut self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Self::Data, Self::Error>>> { let offset = self.offset.unwrap_or(DEFAULT_OFFSET); ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
241
300
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:8
}; } }; } } fn poll_trailers( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<Option<HeaderMap>, Self::Error>> { Poll::Ready(Ok(None)) } fn is_end_stream(&self) -> bool { // fast path end-stream for empty streams ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:9
.as_file() .metadata() .expect("file metadata is accessible") .len(); let body = FsBuilder::new() .path(&file) .buffer_size(16384) .length(Length::Exact(file_length)) .build() .await .unwrap() ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:10
.unwrap(); // Ensure that the file was written to file.flush().expect("flushing is OK"); let body = FsBuilder::new() .path(&file) // The file is longer than 1 byte, let's see if this is used to generate the size hint .length(Length::Exact(1)) .bui...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:11
} #[tokio::test] async fn fsbuilder_length_exact() { let mut file = NamedTempFile::new().unwrap(); let test_sentence = "This sentence is 30 bytes long"; assert_eq!(test_sentence.len(), 30); write!(file, "{}", test_sentence).unwrap(); // Ensure that the file was written ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:12
let line_0 = "Line 0\n"; let line_1 = "Line 1\n"; write!(file, "{}", line_0).unwrap(); write!(file, "{}", line_1).unwrap(); // Ensure that the file was written to file.flush().expect("flushing is OK"); let body = FsBuilder::new() .path(&file) //...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:13
.offset(line_0.len() as u64) // We want to read only line 1 and stop before we get to line 2 .length(Length::Exact(line_1.len() as u64)) .build() .await .unwrap(); let data = body.collect().await.unwrap().into_bytes(); let data_str = String::f...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:14
async fn fsbuilder_with_length_greater_than_file_length_reads_everything() { let mut file = NamedTempFile::new().unwrap(); let line_0 = "Line 0\n"; let line_1 = "Line 1\n"; write!(file, "{}", line_0).unwrap(); write!(file, "{}", line_1).unwrap(); // Ensure that the file...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:15
} // Check we wrote the lines assert!(!in_memory_copy_of_file_contents.is_empty()); } let file_size = file.as_file().metadata().unwrap().len(); // Check that our in-memory copy has the same size as the file assert_eq!(file_size, in_memory_copy_of_file_contents.le...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
305c4aa0a153737d28f3c9cbbf425e5dcd946da1
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/305c4aa0a153737d28f3c9cbbf425e5dcd946da1/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
561
607
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:1
/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ use bytes::Bytes; use futures_core::ready; use http::HeaderMap; use http_body::{Body, SizeHint}; use std::future::Future; use std::path::PathBuf; use std::pin::Pin; use std::task::{Context, Poll}; use to...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
1
60
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:2
impl PathBody { fn from_path(path_buf: PathBuf, length: u64, buffer_size: usize, offset: Option<u64>) -> Self { PathBody { state: State::Unloaded(path_buf), length, buffer_size, offset, } } fn from_file(file: File, length: u64, buffer_size: us...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
41
100
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:3
/// .length(Length::UpTo(123_456)) /// .build() /// .await /// .expect("valid path"); /// GetObjectInput { body: bytestream } /// } /// # } /// ``` pub struct FsBuilder { file: Option<tokio::fs::File>, path: Option<PathBuf>, length: Option<Length>, buffer_size: usize,...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
81
140
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:4
offset: None, path: None, } } /// Sets the path to read from. /// /// NOTE: The resulting ByteStream (after calling [build](FsBuilder::build)) will be retryable. /// The returned ByteStream will provide a size hint when used as an HTTP body. /// If the request fails, the rea...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
121
180
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:5
self } /// Specify the offset to start reading from (in bytes) /// /// When used in conjunction with [`length`](FsBuilder::length), allows for reading a single "chunk" of a file. pub fn offset(mut self, offset: u64) -> Self { self.offset = Some(offset); self } /// Returns a...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
161
220
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:6
None => file_length - offset, }; if let Some(path) = self.path { let body_loader = move || { // If an offset was provided, seeking will be handled in `PathBody::poll_data` each // time the file is loaded. SdkBody::from_dyn(http_body::combinato...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
201
260
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:7
} .map(|metadata| metadata.len()) .map_err(|err| Error(err.into())) } } enum State { Unloaded(PathBuf), Loading(Pin<Box<dyn Future<Output = io::Result<File>> + Send + Sync + 'static>>), Loaded(tokio_util::io::ReaderStream<io::Take<File>>), } impl Body for PathBody { type Data = Byt...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
241
300
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:8
self.buffer_size, )); } Err(e) => return Poll::Ready(Some(Err(e.into()))), }; } State::Loaded(ref mut stream) => { use futures_core::Stream; return matc...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
281
340
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:9
use http_body::Body; use std::io::Write; use tempfile::NamedTempFile; #[tokio::test] async fn path_based_bytestreams_with_builder() { let mut file = NamedTempFile::new().unwrap(); for i in 0..10000 { writeln!(file, "Brian was here. Briefly. {}", i).unwrap(); } ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
321
380
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:10
ByteStream::new(body1).collect().await.unwrap().remaining() as u64, file_length - some_data.len() as u64 ); } #[tokio::test] async fn fsbuilder_length_is_used_as_size_hint() { let mut file = NamedTempFile::new().unwrap(); write!( file, "A very lon...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
361
420
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:11
let body = FsBuilder::new() .path(&file) // We're going to read line 0 only .length(Length::Exact(line_0.len() as u64)) .build() .await .unwrap(); let data = body.collect().await.unwrap().into_bytes(); let data_str = String::from_u...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
401
460
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:12
assert!(FsBuilder::new() .path(&file) // Larger than 30 bytes, this will cause an error .length(Length::Exact(31)) .build() .await .is_err()); } #[tokio::test] async fn fsbuilder_supports_offset() { let mut file = NamedTempFile...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
441
500
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:13
let line_2 = "Line 2\n"; write!(file, "{}", line_0).unwrap(); write!(file, "{}", line_1).unwrap(); write!(file, "{}", line_2).unwrap(); // Ensure that the file was written to file.flush().expect("flushing is OK"); let body = FsBuilder::new() .path(&file) ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
481
540
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:14
// We're going to skip all file contents by setting an offset // much larger than the file size .offset(9000) .build() .await .unwrap_err() .to_string(), "offset must be less than or equal to file size but was gr...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
521
580
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:15
// I put these two write loops in separate blocks so that the traits wouldn't conflict { use std::io::Write; for i in 0..1000 { writeln!(file, "Line {:04}", i).unwrap(); } } { use std::fmt::Write; for i in 0..1000 { ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
561
619
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:16
.await .unwrap(); byte_streams.push(byte_stream); } let mut collected_bytes = Vec::new(); for byte_stream in byte_streams.into_iter() { let bytes = byte_stream.collect().await.unwrap().into_bytes(); collected_bytes.push(bytes); } ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
a89490538b3a9b233a2eac4b518a5bcdea82b823
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/a89490538b3a9b233a2eac4b518a5bcdea82b823/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
601
619
awslabs/aws-sdk-rust:sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs:9
use http_body::Body; use std::io::Write; use tempfile::NamedTempFile; #[tokio::test] async fn path_based_bytestreams_with_builder() { let mut file = NamedTempFile::new().unwrap(); for i in 0..10000 { writeln!(file, "Brian was here. Briefly. {}", i).unwrap(); } ...
rust
rust
rust-source
awslabs/aws-sdk-rust
sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
Apache-2.0
21852936856010a4050d9490d361b929b1e4c664
github
sdk
https://github.com/awslabs/aws-sdk-rust/blob/21852936856010a4050d9490d361b929b1e4c664/sdk/aws-smithy-http/src/byte_stream/bytestream_util.rs
321
380