Type Alias opendal::operator_futures::FutureRead
source · pub type FutureRead<F> = OperatorFuture<(OpRead, OpReader), Buffer, F>;
Expand description
Future that generated by Operator::read_with
.
Users can add more options by public functions provided by this struct.
Aliased Type§
struct FutureRead<F> { /* private fields */ }
Implementations§
source§impl<F: Future<Output = Result<Buffer>>> FutureRead<F>
impl<F: Future<Output = Result<Buffer>>> FutureRead<F>
sourcepub fn range(self, range: impl RangeBounds<u64>) -> Self
pub fn range(self, range: impl RangeBounds<u64>) -> Self
Set range
for this read
request.
If we have a file with size n
.
..
means read bytes in range[0, n)
of file.0..1024
and..1024
means read bytes in range[0, 1024)
of file1024..
means read bytes in range[1024, n)
of file
let bs = op.read_with("path/to/file").range(0..1024).await?;
sourcepub fn concurrent(self, concurrent: usize) -> Self
pub fn concurrent(self, concurrent: usize) -> Self
Set concurrent
for the reader.
OpenDAL by default to write file without concurrent. This is not efficient for cases when users
read large chunks of data. By setting concurrent
, opendal will read files concurrently
on support storage services.
By setting concurrent
, opendal will fetch chunks concurrently with
the given chunk size.
let r = op.read_with("path/to/file").concurrent(8).await?;
sourcepub fn chunk(self, chunk_size: usize) -> Self
pub fn chunk(self, chunk_size: usize) -> Self
OpenDAL will use services’ preferred chunk size by default. Users can set chunk based on their own needs.
This following example will make opendal read data in 4MiB chunks:
let r = op.read_with("path/to/file").chunk(4 * 1024 * 1024).await?;
sourcepub fn version(self, v: &str) -> Self
pub fn version(self, v: &str) -> Self
Set version
for this read
request.
This feature can be used to retrieve the data of a specified version of the given path.
If the version doesn’t exist, an error with kind ErrorKind::NotFound
will be returned.
let mut bs = op.read_with("path/to/file").version(version).await?;
sourcepub fn if_match(self, v: &str) -> Self
pub fn if_match(self, v: &str) -> Self
Set if_match
for this read
request.
This feature can be used to check if the file’s ETag
matches the given ETag
.
If file exists and it’s etag doesn’t match, an error with kind ErrorKind::ConditionNotMatch
will be returned.
use opendal::Operator;
let mut metadata = op.read_with("path/to/file").if_match(etag).await?;
sourcepub fn if_none_match(self, v: &str) -> Self
pub fn if_none_match(self, v: &str) -> Self
Set if_none_match
for this read
request.
This feature can be used to check if the file’s ETag
doesn’t match the given ETag
.
If file exists and it’s etag match, an error with kind ErrorKind::ConditionNotMatch
will be returned.
use opendal::Operator;
let mut metadata = op.read_with("path/to/file").if_none_match(etag).await?;
sourcepub fn if_modified_since(self, v: DateTime<Utc>) -> Self
pub fn if_modified_since(self, v: DateTime<Utc>) -> Self
§if_modified_since
Set if_modified_since
for this read
request.
This feature can be used to check if the file has been modified since the given timestamp.
If file exists and it hasn’t been modified since the specified time, an error with kind
ErrorKind::ConditionNotMatch
will be returned.
use opendal::Operator;
use chrono::DateTime;
use chrono::Utc;
let mut metadata = op.read_with("path/to/file").if_modified_since(time).await?;
sourcepub fn if_unmodified_since(self, v: DateTime<Utc>) -> Self
pub fn if_unmodified_since(self, v: DateTime<Utc>) -> Self
Set if_unmodified_since
for this read
request.
This feature can be used to check if the file hasn’t been modified since the given timestamp.
If file exists and it has been modified since the specified time, an error with kind
ErrorKind::ConditionNotMatch
will be returned.
use opendal::Operator;
use chrono::DateTime;
use chrono::Utc;
let mut metadata = op.read_with("path/to/file").if_unmodified_since(time).await?;