Skip to main content

WrapFileBuilder

Struct WrapFileBuilder 

Source
pub struct WrapFileBuilder<'a, R: Read> { /* private fields */ }
Expand description

Builder for creating a ProgressReader with optional configuration.

§Example

use std::fs::File;
use std::io::Read;
use rich_rs::{Progress, WrapFileBuilder};
use rich_rs::live::LiveOptions;

let progress = Progress::new_default(LiveOptions::default(), false, false, false);
let file = File::open("data.bin").unwrap();

let reader = WrapFileBuilder::new(&progress, file)
    .total(1024)
    .description("Processing...")
    .build();

Implementations§

Source§

impl<'a, R: Read> WrapFileBuilder<'a, R>

Source

pub fn new(progress: &'a Progress, reader: R) -> Self

Create a new builder with the given progress and reader.

Source

pub fn total(self, total: u64) -> Self

Set the total number of bytes expected to be read.

Source

pub fn total_opt(self, total: Option<u64>) -> Self

Set an optional total (None for indeterminate progress).

Source

pub fn task_id(self, task_id: TaskID) -> Self

Use an existing task instead of creating a new one.

Source

pub fn description(self, description: impl Into<String>) -> Self

Set the description for the task (used when creating a new task).

Source

pub fn close_handle(self, close: bool) -> Self

Set whether the inner handle should be considered “owned” and closed.

Source

pub fn build(self) -> ProgressReader<'a, R>

Build the ProgressReader.

If no task_id was provided, a new task is created with the configured description and total.

Auto Trait Implementations§

§

impl<'a, R> Freeze for WrapFileBuilder<'a, R>
where R: Freeze,

§

impl<'a, R> !RefUnwindSafe for WrapFileBuilder<'a, R>

§

impl<'a, R> Send for WrapFileBuilder<'a, R>
where R: Send,

§

impl<'a, R> Sync for WrapFileBuilder<'a, R>
where R: Sync,

§

impl<'a, R> Unpin for WrapFileBuilder<'a, R>
where R: Unpin,

§

impl<'a, R> !UnwindSafe for WrapFileBuilder<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.