Struct glommio::io::DmaStreamReaderBuilder[][src]

pub struct DmaStreamReaderBuilder { /* fields omitted */ }
Expand description

Builds a DmaStreamReader, allowing linear access to a Direct I/O DmaFile

Implementations

Creates a new DmaStreamReaderBuilder, given a shared pointer to a DmaFile

This method is useful in situations where a shared pointer was already present. For example if you need to scan a header in the file and also make it available for random reads.

Other than that, it is the same as new

Examples

use glommio::{
    io::{DmaFile, DmaStreamReaderBuilder},
    Local,
    LocalExecutor,
};
use std::rc::Rc;

let ex = LocalExecutor::default();
ex.run(async {
    let file = Rc::new(DmaFile::open("myfile.txt").await.unwrap());
    let _reader = DmaStreamReaderBuilder::from_rc(file.clone()).build();

    // issue random I/O now, even though a stream is open.
    Local::local(async move {
        file.read_at(0, 8).await.unwrap();
    })
    .await;
});

Creates a new DmaStreamReaderBuilder, given a DmaFile

Various properties can be set by using its with methods.

A DmaStreamReader can later be constructed from it by calling build

Examples

use glommio::{
    io::{DmaFile, DmaStreamReaderBuilder},
    LocalExecutor,
};

let ex = LocalExecutor::default();
ex.run(async {
    let file = DmaFile::open("myfile.txt").await.unwrap();
    let _reader = DmaStreamReaderBuilder::new(file).build();
});

Define a starting position.

Reads from the DmaStreamReader will start from this position

Define an end position.

Reads from the DmaStreamReader will end at this position even if the file is larger.

Define the number of read-ahead buffers that will be used by the DmaStreamReader

Higher read-ahead numbers mean more parallelism but also more memory usage.

Define the buffer size that will be used by the DmaStreamReader

Builds a DmaStreamReader with the properties defined by this DmaStreamReaderBuilder

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Performs the conversion.

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.