1use std::ops::{Deref, DerefMut};
2use std::hash::{Hash, Hasher};
3use std::borrow::Borrow;
4
5use crate::Cookie;
6
7#[derive(Clone, Debug)]
13pub(crate) struct DeltaCookie {
14 pub cookie: Cookie<'static>,
15 pub removed: bool,
16}
17
18impl DeltaCookie {
19 #[inline]
21 pub fn added(cookie: Cookie<'static>) -> DeltaCookie {
22 DeltaCookie { cookie, removed: false, }
23 }
24
25 #[inline]
28 pub fn removed(cookie: Cookie<'static>) -> DeltaCookie {
29 DeltaCookie { cookie, removed: true, }
30 }
31}
32
33impl Deref for DeltaCookie {
34 type Target = Cookie<'static>;
35
36 fn deref(&self) -> &Cookie<'static> {
37 &self.cookie
38 }
39}
40
41impl DerefMut for DeltaCookie {
42 fn deref_mut(&mut self) -> &mut Cookie<'static> {
43 &mut self.cookie
44 }
45}
46
47impl PartialEq for DeltaCookie {
48 fn eq(&self, other: &DeltaCookie) -> bool {
49 self.name() == other.name()
50 }
51}
52
53impl Eq for DeltaCookie {}
54
55impl Hash for DeltaCookie {
56 fn hash<H: Hasher>(&self, state: &mut H) {
57 self.name().hash(state);
58 }
59}
60
61impl Borrow<str> for DeltaCookie {
62 fn borrow(&self) -> &str {
63 self.name()
64 }
65}