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§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyPart
impl<'de> Deserialize<'de> for KeyPart
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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 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