Packages / rupm

rs-net-etag 0.1.0

ETag generation, weak and strong comparison, If-None-Match / If-Match evaluation and Range header parsing

Install

cargo add rs-net-etag --registry rupm

In Ruststudio: Packages, search for rs-net-etag, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.

Versions

README

# rs-net-etag

Generates ETags from bytes, compares them weakly and strongly, evaluates If-None-Match and If-Match headers per RFC 9110 and parses Range headers into inclusive byte ranges clamped to the resource size.

## Install

Add it with `rupm add rs-net-etag` (or `cargo add rs-net-etag --registry rupm`).

## Usage

```rust
use rs_net_etag::{if_none_match_allows, parse_range, ETag};

let tag = ETag::from_bytes(b"hello");
let fresh = !if_none_match_allows(&tag.to_string(), Some(&tag)); // true: reply 304
let ranges = parse_range("bytes=0-4,-2", 10).unwrap();
```

## API overview

- `ETag`: `from_bytes`, `strong`, `weak`, `parse`, `strong_eq`, `weak_eq`, `into_weak`, `Display`
- `parse_list`, `if_none_match_allows`, `if_match_allows`
- `parse_range(header, total) -> Result<Vec<ByteRange>, RangeError>`, `ByteRange::content_range`