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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! Filtering functionality for cache queries.
//!
//! This module provides different types of filters that can be applied when listing cache entries.
//! Filters allow you to narrow down results based on key patterns.
/// Enum representing different filter types for cache queries.
///
/// Filters are used with the `list` method to narrow down results based on key patterns.
///
/// # Examples
///
/// ```
/// use quickleaf::Filter;
/// use quickleaf::Cache;
/// use quickleaf::ListProps;
/// use quickleaf::valu3::traits::ToValueBehavior;
///
/// let mut cache = Cache::new(10);
/// cache.insert("apple_pie", 1);
/// cache.insert("banana_split", 2);
/// cache.insert("apple_juice", 3);
/// cache.insert("grape_juice", 4);
///
/// // Filter by prefix
/// let start_filter = Filter::StartWith("apple".to_string());
/// let props = ListProps::default().filter(start_filter);
/// let results = cache.list(props).unwrap();
/// assert_eq!(results.len(), 2);
///
/// // Filter by suffix
/// let end_filter = Filter::EndWith("juice".to_string());
/// let props = ListProps::default().filter(end_filter);
/// let results = cache.list(props).unwrap();
/// assert_eq!(results.len(), 2);
///
/// // Filter by both prefix and suffix
/// let both_filter = Filter::StartAndEndWith("apple".to_string(), "juice".to_string());
/// let props = ListProps::default().filter(both_filter);
/// let results = cache.list(props).unwrap();
/// assert_eq!(results.len(), 1);
/// ```