Crates.io | entity-tag |
lib.rs | entity-tag |
version | 0.1.8 |
source | src |
created_at | 2021-04-21 10:58:38.778657 |
updated_at | 2023-09-11 05:00:10.287212 |
description | This crate provides a `EntityTag` structure and functions to deal with the ETag header field of HTTP. |
homepage | https://magiclen.org/entity-tag |
repository | https://github.com/magiclen/entity-tag |
max_upload_size | |
id | 387557 |
size | 14,550 |
This crate provides a EntityTag
structure and functions to deal with the ETag header field of HTTP.
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"
Disable the default features to compile this crate without std.
[dependencies.entity-tag]
version = "*"
default-features = false
https://crates.io/crates/entity-tag