Skip to content

Commit

Permalink
Make features additive
Browse files Browse the repository at this point in the history
  • Loading branch information
pka committed Aug 30, 2023
1 parent 6912245 commit e409739
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 195 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --target ${{matrix.target}}
args: --target ${{matrix.target}} --no-default-features --features=reqwest-async

test:
strategy:
Expand Down Expand Up @@ -62,12 +62,8 @@ jobs:
command: test
args: --target ${{matrix.target}} --all-features -- --test-threads 1

# This is currently broken because
# reqwest is not actually optional
#
# - name: test --no-default-features
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --target ${{matrix.target}} --no-default-features

- name: test --no-default-features
uses: actions-rs/cargo@v1
with:
command: test
args: --target ${{matrix.target}} --no-default-features
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ license = "MIT/Apache-2.0"
keywords = ["http", "reader", "buffer"]

[features]
default = ["reqwest"]
sync = ["reqwest?/blocking"]
default = ["reqwest-sync", "reqwest-async"]
logging = ["log"]
reqwest-async = ["reqwest"]
reqwest-sync = ["reqwest/blocking"]

[dependencies]
byteorder = "1.4.2"
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

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

Implements Seek+Read for blocking clients, which makes it a drop-in replacement for local files.

Usage example:
Usage examples:

use http_range_client::*;

Expand All @@ -12,3 +13,10 @@ Usage example:
assert_eq!(bytes, b"fgb");
let version = client.get_bytes(1).await?; // From buffer - no HTTP request!
assert_eq!(version, [3]);

let mut client =
HttpReader::new("https://www.rust-lang.org/static/images/favicon-32x32.png");
client.seek(SeekFrom::Start(1)).ok();
let mut bytes = [0; 3];
client.read_exact(&mut bytes)?;
assert_eq!(&bytes, b"PNG");
Loading

0 comments on commit e409739

Please sign in to comment.