pub fn download(
remote_path: &str,
local_path: &str,
header: Option<HashMap<String, String>>
) -> Result<(), OneIoError>
Expand description
Downloads a file from a remote location to a local path.
§Arguments
remote_path
- The remote path of the file to download.local_path
- The local path where the downloaded file will be saved.header
- Optional header information to include in the request. If not specified, an empty HashMap should be provided.
§Errors
Returns an Err
variant of OneIoError
if any of the following occur:
- The protocol of the remote path is not supported.
- An error occurs while downloading the file.
§Example
use std::collections::HashMap;
use crate::oneio::{download, OneIoError};
fn main() -> Result<(), OneIoError> {
let remote_path = "https://example.com/file.txt";
let local_path = "path/to/save/file.txt";
let header: Option<HashMap<String, String>> = None;
download(remote_path, local_path, header)?;
Ok(())
}