Trait ReadProgressWrapper

Source
pub trait ReadProgressWrapper {
    // Required methods
    fn init(
        self: Box<Self>,
        len: u64,
        asset: &GeAsset,
    ) -> Box<dyn ReadProgressWrapper>;
    fn wrap(&self, reader: Box<dyn Read>) -> Box<dyn Read>;
    fn finish(&self, release: &GeAsset);
}
Expand description

Trait defining how to determine the progress for a Read type.

This trait helps with providing progress information when performing a download. Currently, this trait is mostly focused on providing a working implementation with the indicatif crate due to that crate being used in ge_man itself. Therefore, this trait might not work too well with other progress tracking crates.

Required Methods§

Source

fn init( self: Box<Self>, len: u64, asset: &GeAsset, ) -> Box<dyn ReadProgressWrapper>

Tells the implementing struct how to construct itself. For example, indicatif requires a progress bar struct to be created that performs the tracking of a Read type.

§Examples
use ge_man_lib::download::ReadProgressWrapper;

fn init(self: Box<Self>, len: u64) -> Box<dyn ReadProgressWrapper> {
    let pb = ProgressBar::with_draw_target(len, ProgressDrawTarget::stdout())
    .with_style(style())
    .with_message("Downloading archive:");

    Box::new(DownloadProgressTracker::new(pb))
}
Source

fn wrap(&self, reader: Box<dyn Read>) -> Box<dyn Read>

Wrap the actual Read type, which is the resource to be downloaded, with a progress tracking reader.

Source

fn finish(&self, release: &GeAsset)

Define how the implementing struct should finish tracking progress.

Implementors§