Skip to content

Commit 6f1ffec

Browse files
tottotojoseluisq
authored andcommitted
Remove bitflags (hyperium#135)
1 parent 7abc45b commit 6f1ffec

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ members = [
2020
http = "0.2.0"
2121
headers-core = "0.2"
2222
base64 = "0.13"
23-
bitflags = "1.0"
24-
itertools = "0.9"
2523
bytes = "1"
2624
mime = "0.3.14"
2725
sha1 = "0.10"

src/common/cache_control.rs

+26-11
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,32 @@ pub struct CacheControl {
4444
s_max_age: Option<Seconds>,
4545
}
4646

47-
bitflags! {
48-
struct Flags: u32 {
49-
const NO_CACHE = 0b000000001;
50-
const NO_STORE = 0b000000010;
51-
const NO_TRANSFORM = 0b000000100;
52-
const ONLY_IF_CACHED = 0b000001000;
53-
const MUST_REVALIDATE = 0b000010000;
54-
const PUBLIC = 0b000100000;
55-
const PRIVATE = 0b001000000;
56-
const PROXY_REVALIDATE = 0b010000000;
57-
const IMMUTABLE = 0b100000000;
47+
#[derive(Debug, Clone, PartialEq)]
48+
struct Flags {
49+
bits: u64,
50+
}
51+
52+
impl Flags {
53+
const NO_CACHE: Self = Self { bits: 0b000000001 };
54+
const NO_STORE: Self = Self { bits: 0b000000010 };
55+
const NO_TRANSFORM: Self = Self { bits: 0b000000100 };
56+
const ONLY_IF_CACHED: Self = Self { bits: 0b000001000 };
57+
const MUST_REVALIDATE: Self = Self { bits: 0b000010000 };
58+
const PUBLIC: Self = Self { bits: 0b000100000 };
59+
const PRIVATE: Self = Self { bits: 0b001000000 };
60+
const PROXY_REVALIDATE: Self = Self { bits: 0b010000000 };
61+
const IMMUTABLE: Self = Self { bits: 0b100000000 };
62+
63+
fn empty() -> Self {
64+
Self { bits: 0 }
65+
}
66+
67+
fn contains(&self, flag: Self) -> bool {
68+
(self.bits & flag.bits) != 0
69+
}
70+
71+
fn insert(&mut self, flag: Self) {
72+
self.bits |= flag.bits;
5873
}
5974
}
6075

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
//! ```
7474
7575
extern crate base64;
76-
#[macro_use]
77-
extern crate bitflags;
7876
extern crate bytes;
7977
extern crate headers_core;
8078
extern crate http;

0 commit comments

Comments
 (0)