Crate remozipsy

Crate remozipsy 

Source
Expand description

This crate enables you to sync the content from a remote zip file to a local filesystem, WITHOUT fetching the entire file.

§Usage

See example: sync_remote_zip

use remozipsy::{Config, Statemachine, reqwest::ReqwestRemoteZip, tokio::TokioLocalStorage};

#[tokio::main(flavor = "current_thread")]
pub async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let remote =
        ReqwestRemoteZip::with_url("https://getsamplefiles.com/download/zip/sample-1.zip")?;
    let local = TokioLocalStorage::new("./extract".into(), Vec::new());
    let mut state = Statemachine::new(remote, local, Config::default());

    while let Some((progress, next_state)) = state.progress().await {
        state = next_state;
        println!("Progress: {progress:?}");
        tokio::task::yield_now().await;
    }
    Ok(())
}

Modules§

reqwest
Default implementations for RemoteZip that are only available with the reqwest feature enabled.
tokio
Default implementations for FileSystem that are only available with the tokio feature enabled.

Structs§

Config
Configurations for the state machine
FileInfo
Used in this crate’s traits to interact with FileSystem and RemoteZip
ProgressDetails
Indicates progress based on bytes, e.g. for filesystem or remote operation
RemoteFileInfo
Use this to provide internal zip information to this crate. If you don’t want to go low-level and build this yourself, use the fetch_remote_file_info helper method.
Statemachine
Main struct to sync remote with local via Self::progress.

Enums§

Error
Progress
RemoteFetchError

Traits§

FileSystem
This trait is used to access the local file system. You can implement it according to your needs or use the crate::tokio::TokioLocalStorage struct. Note: try to avoid parallel modifications to the Filesystem during execution time of the statemachine.
RemoteZip
This trait is used to access the remote zip file. You can implement it according to your needs or use the crate::reqwest::ReqwestRemoteZip struct. Note: the zip MUST NOT change during execution time of the statemachine.

Functions§

calculate_local_unix_path
Helper function that can be used if you want to build your own crate::FileSystem
fetch_remote_file_info
Helper function to read RemoteFileInfo if you can provide zip size and a fetch function.