pub struct FsBuilder { /* private fields */ }
Expand description

Builder for creating ByteStreams from a file/path, with full control over advanced options.

Example usage:

use aws_smithy_http::byte_stream::{ByteStream, Length};
use std::path::Path;
struct GetObjectInput {
    body: ByteStream
}

async fn bytestream_from_file() -> GetObjectInput {
    let bytestream = ByteStream::read_from()
        .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::UpTo(123_456))
        .build()
        .await
        .expect("valid path");
    GetObjectInput { body: bytestream }
}

Implementations

Create a new FsBuilder (using a default read buffer of 4096 bytes).

You must then call either file or path to specify what to read from.

Sets the path to read from.

NOTE: The resulting ByteStream (after calling 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 handle.

Sets the file to read from.

NOTE: The resulting ByteStream (after calling build) will not be a retryable ByteStream. For a ByteStream that can be retried in the case of upstream failures, use FsBuilder::path.

Specify the length to read (in bytes).

By pre-specifying the length, this API skips an additional call to retrieve the size from file-system metadata.

When used in conjunction with offset, allows for reading a single “chunk” of a file.

Specify the size of the buffer used to read the file (in bytes).

Increasing the read buffer capacity to higher values than the default (4096 bytes) can result in a large reduction in CPU usage, at the cost of memory increase.

Specify the offset to start reading from (in bytes)

When used in conjunction with length, allows for reading a single “chunk” of a file.

Returns a ByteStream from this builder.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more