Skip to content

Commit

Permalink
Fix serde feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 29, 2023
1 parent 1260c46 commit 8fba3b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "http-cache-semantics"
version = "2.0.0"
version = "2.0.1"
description = "RFC 7234. Parses HTTP headers to correctly compute cacheability of responses, even in complex cases"
homepage = "https://lib.rs/http-cache-semantics"
repository = "https://github.com/kornelski/rusty-http-cache-semantics"
Expand All @@ -17,9 +17,9 @@ rust-version = "1.64"
[dependencies]
http = "1.0.0"
http-serde = { version = "2.0.0", optional = true }
serde = { version = "1.0.192", optional = true, features = ["derive"] }
serde = { version = "1.0.193", optional = true, features = ["derive"] }
# reqwest = { version = "0.11.22", default-features = false, optional = true } # not upgraded yet
time = { version = "0.3.30", features = ["parsing", "formatting"] }
time = { version = "0.3.20", features = ["parsing", "formatting"] }

[dev-dependencies]
serde_json = "1.0.108"
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn format_cache_control(cc: &CacheControl) -> String {

/// Configuration options which control behavior of the cache. Use with `CachePolicy::new_options()`.
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CacheOptions {
/// If `true` (default), then the response is evaluated from a
/// perspective of a shared cache (i.e. `private` is not cacheable and
Expand Down Expand Up @@ -152,17 +152,17 @@ impl Default for CacheOptions {
/// tricky details such as the Vary header, proxy revalidation, and
/// authenticated responses.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "with_serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CachePolicy {
#[cfg_attr(feature = "with_serde", serde(with = "http_serde::header_map"))]
#[cfg_attr(feature = "serde", serde(with = "http_serde::header_map"))]
req: HeaderMap,
#[cfg_attr(feature = "with_serde", serde(with = "http_serde::header_map"))]
#[cfg_attr(feature = "serde", serde(with = "http_serde::header_map"))]
res: HeaderMap,
#[cfg_attr(feature = "with_serde", serde(with = "http_serde::uri"))]
#[cfg_attr(feature = "serde", serde(with = "http_serde::uri"))]
uri: Uri,
#[cfg_attr(feature = "with_serde", serde(with = "http_serde::status_code"))]
#[cfg_attr(feature = "serde", serde(with = "http_serde::status_code"))]
status: StatusCode,
#[cfg_attr(feature = "with_serde", serde(with = "http_serde::method"))]
#[cfg_attr(feature = "serde", serde(with = "http_serde::method"))]
method: Method,
opts: CacheOptions,
res_cc: CacheControl,
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ fn test_proxy_cacheable_auth_is_ok() {
assert_eq!(policy.is_stale(now), false);
assert!(policy.is_storable());

#[cfg(feature = "with_serde")]
#[cfg(feature = "serde")]
{
let json = serde_json::to_string(&policy).unwrap();
let policy: CachePolicy = serde_json::from_str(&json).unwrap();
Expand Down Expand Up @@ -575,7 +575,7 @@ fn test_weird_syntax() {
assert_eq!(policy.is_stale(now), false);
assert_eq!((policy.time_to_live(now) + policy.age(now)).as_secs(), 456);

#[cfg(feature = "with_serde")]
#[cfg(feature = "serde")]
{
let json = serde_json::to_string(&policy).unwrap();
let policy: CachePolicy = serde_json::from_str(&json).unwrap();
Expand Down

0 comments on commit 8fba3b9

Please sign in to comment.