alvra / reqwest-file

Use web resources like regular async files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reqwest-File

Build status Crates.io Documentation unsafe forbidden

Use web resources like regular async files.

Features

  • No unsafe code (#[forbid(unsafe_code)])
  • Tested; code coverage: 100%

Example

use reqwest_file::RequestFile;
use tokio::io::{AsyncReadExt, AsyncSeekExt};

let client = reqwest::Client::new();
let request = client.get("http://httpbin.org/base64/aGVsbG8gd29ybGQ=");
let mut file: RequestFile = RequestFile::new(request);

let mut buffer = [0; 5];
assert_eq!(file.read(&mut buffer).await.unwrap(), 5);
assert_eq!(&buffer, b"hello");

let mut buffer = [0; 5];
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).await.unwrap(), 6);
assert_eq!(file.read(&mut buffer).await.unwrap(), 5);
assert_eq!(&buffer, b"world");

Documentation

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Use web resources like regular async files

License:Apache License 2.0


Languages

Language:Rust 100.0%