Crate http_range_client

source ·
Expand description

HTTP client for HTTP Range requests with a buffer optimized for sequential reading.

§Usage example

use http_range_client::*;

// Async API
let mut client = BufferedHttpRangeClient::new("https://flatgeobuf.org/test/data/countries.fgb");
let bytes = client.min_req_size(256).get_range(0, 3).await?;
assert_eq!(bytes, b"fgb");
let version = client.get_bytes(1).await?; // From buffer - no HTTP request!
assert_eq!(version, [3]);

// Blocking API
let mut client = HttpReader::new("https://flatgeobuf.org/test/data/countries.fgb");
let bytes = client.min_req_size(256).get_range(0, 3)?;
assert_eq!(bytes, b"fgb");
let version = client.get_bytes(1)?; // From buffer - no HTTP request!
assert_eq!(version, [3]);

// Seek+Read API
use std::io::{Read, Seek, SeekFrom};
let mut reader = HttpReader::new("https://www.rust-lang.org/static/images/favicon-32x32.png");
reader.seek(SeekFrom::Start(1)).ok();
let mut bytes = [0; 3];
reader.read_exact(&mut bytes)?;
assert_eq!(&bytes, b"PNG");

Structs§

Enums§

Traits§

Type Aliases§

  • Async HTTP client for HTTP Range requests with a buffer optimized for sequential reading.
  • Sync HTTP client for HTTP Range requests with a buffer optimized for sequential reading.
  • Sync HTTP client for HTTP Range requests with a buffer optimized for sequential reading.