pub struct EntityKey {
pub entity_type: String,
pub entity_id: String,
}Expand description
Type-safe entity key for cache invalidation.
Combines entity type and ID into a single, hashable key for use in dependency tracking and cache invalidation.
Fields§
§entity_type: StringEntity type (e.g., “User”, “Post”)
entity_id: StringEntity ID (UUID)
Implementations§
Source§impl EntityKey
impl EntityKey
Sourcepub fn new(entity_type: &str, entity_id: &str) -> Result<Self>
pub fn new(entity_type: &str, entity_id: &str) -> Result<Self>
Create a new entity key with validation.
§Arguments
entity_type- The type of entity (must be non-empty)entity_id- The entity’s unique identifier (must be non-empty)
§Returns
Ok(EntityKey)- If both arguments are validErr(_)- If either argument is empty
§Examples
use fraiseql_core::cache::EntityKey;
let key = EntityKey::new("User", "550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(key.entity_type, "User");Sourcepub fn to_cache_key(&self) -> String
pub fn to_cache_key(&self) -> String
Convert entity key to cache key format: “EntityType:entity_id”
§Examples
use fraiseql_core::cache::EntityKey;
let key = EntityKey::new("User", "550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(key.to_cache_key(), "User:550e8400-e29b-41d4-a716-446655440000");Sourcepub fn from_cache_key(cache_key: &str) -> Result<Self>
pub fn from_cache_key(cache_key: &str) -> Result<Self>
Parse entity key from cache key format: “EntityType:entity_id”
§Arguments
cache_key- String in format “Type:id”
§Returns
Ok(EntityKey)- If format is validErr(_)- If format is invalid
§Examples
use fraiseql_core::cache::EntityKey;
let key = EntityKey::from_cache_key("User:550e8400-e29b-41d4-a716-446655440000").unwrap();
assert_eq!(key.entity_type, "User");Trait Implementations§
Source§impl Ord for EntityKey
impl Ord for EntityKey
Source§impl PartialOrd for EntityKey
impl PartialOrd for EntityKey
impl Eq for EntityKey
impl StructuralPartialEq for EntityKey
Auto Trait Implementations§
impl Freeze for EntityKey
impl RefUnwindSafe for EntityKey
impl Send for EntityKey
impl Sync for EntityKey
impl Unpin for EntityKey
impl UnsafeUnpin for EntityKey
impl UnwindSafe for EntityKey
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.