pub struct KeyPart { /* private fields */ }Expand description
A single component of a cache key.
Each part represents a key-value pair extracted from a request. The value is optional - some parts may be key-only (flags).
§String Optimization
Both key and value use SmolStr which stores small strings (≤23 bytes)
inline without heap allocation. This is efficient for typical cache key
components like “method”, “path”, “GET”, etc.
§Example
use hitbox_core::KeyPart;
// Key with value
let method = KeyPart::new("method", Some("GET"));
assert_eq!(method.key(), "method");
assert_eq!(method.value(), Some("GET"));
// Key without value (flag)
let flag = KeyPart::new("cached", None::<&str>);
assert_eq!(flag.key(), "cached");
assert_eq!(flag.value(), None);Implementations§
Source§impl KeyPart
impl KeyPart
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyPart
impl<'de> Deserialize<'de> for KeyPart
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<KeyPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<KeyPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for KeyPart
impl Serialize for KeyPart
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Decode<'de> for KeyPart
impl Encode for KeyPart
impl Eq for KeyPart
impl StructuralPartialEq for KeyPart
Auto Trait Implementations§
impl Freeze for KeyPart
impl RefUnwindSafe for KeyPart
impl Send for KeyPart
impl Sync for KeyPart
impl Unpin for KeyPart
impl UnsafeUnpin for KeyPart
impl UnwindSafe for KeyPart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CachedFieldClone for Twhere
T: Clone,
impl<T> CachedFieldClone for Twhere
T: Clone,
Source§fn cached_clone(&self) -> T
fn cached_clone(&self) -> T
Clone this field for cache storage.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.