| Crates.io | rseek |
| lib.rs | rseek |
| version | 0.3.0 |
| created_at | 2025-03-20 17:46:18.885283+00 |
| updated_at | 2025-06-10 04:01:22.379272+00 |
| description | rseek is an adapter for reqwest that allows seeking in the response body stream using AsyncSeek |
| homepage | |
| repository | https://github.com/sam0x17/rseek |
| max_upload_size | |
| id | 1599517 |
| size | 62,395 |
Provides a seekable and asynchronous read interface for reqwest HTTP streams that allows
you to seek forward or backward in an HTTP stream without having to download all the
intermediate data. This is useful for handling large files over HTTP where random access is
required.
use reqwest::Client;
use tokio::io::{AsyncReadExt, AsyncSeekExt, SeekFrom};
#[tokio::main]
async fn main() {
use rseek::Seekable;
let client = Client::new();
let mut stream = Seekable::new(move || client.get("https://example.com/largefile.bin")).await;
let mut buf = vec![0u8; 16];
stream.read_exact(&mut buf).await.unwrap();
println!("First 16 bytes: {:?}", buf);
stream.seek(SeekFrom::Start(1_000_000)).await.unwrap();
stream.read_exact(&mut buf).await.unwrap();
println!("Bytes after seeking to 1MB: {:?}", buf);
}
UnexpectedEof if attempting to read past the end of the file.InvalidInput if seeking to a negative position.Unsupported if seeking from the end when the file size is unknown.