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

pub struct DmaStreamReaderBuilder { /* fields omitted */ }

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

Implementations

impl DmaStreamReaderBuilder[src]

#[must_use = "The builder must be built to be useful"]
pub fn from_rc(file: Rc<DmaFile>) -> DmaStreamReaderBuilder
[src]

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;
});

#[must_use = "The builder must be built to be useful"]
pub fn new(file: DmaFile) -> DmaStreamReaderBuilder
[src]

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();
});

pub fn with_start_pos(self, start: u64) -> Self[src]

Define a starting position.

Reads from the DmaStreamReader will start from this position

pub fn with_end_pos(self, end: u64) -> Self[src]

Define an end position.

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

pub fn with_read_ahead(self, read_ahead: usize) -> Self[src]

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.

pub fn with_buffer_size(self, buffer_size: usize) -> Self[src]

Define the buffer size that will be used by the DmaStreamReader

pub fn build(self) -> DmaStreamReader[src]

Builds a DmaStreamReader with the properties defined by this DmaStreamReaderBuilder

Trait Implementations

impl Clone for DmaStreamReaderBuilder[src]

impl Debug for DmaStreamReaderBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.