#http-header #etag #if-match #if-none-match

no-std entity-tag

This crate provides a EntityTag structure and functions to deal with the ETag header field of HTTP

8 releases

0.1.8 Sep 11, 2023
0.1.7 Apr 6, 2023
0.1.6 Mar 6, 2022
0.1.5 Apr 26, 2021

#1306 in Parser implementations

Download history 59/week @ 2024-07-22 89/week @ 2024-07-29 46/week @ 2024-08-05 66/week @ 2024-08-12 47/week @ 2024-08-19 41/week @ 2024-08-26 136/week @ 2024-09-02 94/week @ 2024-09-09 47/week @ 2024-09-16 127/week @ 2024-09-23 53/week @ 2024-09-30 19/week @ 2024-10-07 53/week @ 2024-10-14 46/week @ 2024-10-21 47/week @ 2024-10-28 61/week @ 2024-11-04

208 downloads per month
Used in 10 crates (via rocket-etag-if-none-match)

MIT license

14KB
264 lines

Entity Tag

CI

This crate provides a EntityTag structure and functions to deal with the ETag header field of HTTP.

Examples

use entity_tag::EntityTag;

let etag1 = EntityTag::with_str(true, "foo").unwrap();
let etag2 = EntityTag::from_str("\"foo\"").unwrap();

assert_eq!(true, etag1.weak);
assert_eq!(false, etag2.weak);

assert!(etag1.weak_eq(&etag2));
assert!(etag1.strong_ne(&etag2));

let etag3 = EntityTag::from_data(true, &[102, 111, 111]).unwrap();
assert_eq!("W/\"972Sf7Z4eu8\"", etag3.to_string());

let etag4 = EntityTag::from_file_meta(&std::fs::File::open("tests/data/P1060382.JPG").unwrap().metadata().unwrap());
println!("{}", etag4) // W/"HRScBWR0Mf4"

No Std

Disable the default features to compile this crate without std.

[dependencies.entity-tag]
version = "*"
default-features = false

Crates.io

https://crates.io/crates/entity-tag

Documentation

https://docs.rs/entity-tag

License

MIT

Dependencies

~340KB