1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Copyright (c) 2025-2026, Kirky.X
//!
//! MIT License
//!
//! Cacheable trait for types that can be stored in cache
/// Trait for types that can be stored in and retrieved from cache
///
/// This trait combines serialization and deserialization requirements
/// for cache values. Any type that implements `Serialize` and `DeserializeOwned`
/// automatically implements `Cacheable`.
///
/// # Example
///
/// ```rust,ignore
/// use serde::{Deserialize, Serialize};
/// use oxcache::traits::Cacheable;
///
/// #[derive(Debug, Serialize, Deserialize, PartialEq)]
/// struct User {
/// id: u64,
/// name: String,
/// }
///
/// // User automatically implements Cacheable
/// let user = User {
/// id: 123,
/// name: "Alice".to_string(),
/// };
///
/// // Can be stored in cache
/// // cache.set("user:123", &user).await?;
/// ```
///
/// # Type Bounds
///
/// - `Sized`: The type must have a known size at compile time
/// - `Serialize`: The type must be serializable to bytes
/// - `DeserializeOwned`: The type must be deserializable from owned data
// Blanket implementation for all types that meet the bounds