pub struct Dump<K, V> {
pub capacity: usize,
pub data: Vec<(K, V)>,
}
Expand description
Complete dump of a LRU cache, easily (de)serializable.
It reflects the complete current state of the cache, including key/value pairs but also capacity and order.
Can be used to import/export the cache and serialize/unserialize it.
§Examples
use hashlru::{Cache, Dump};
let mut cache: Cache<&str, usize> = Cache::new(10);
cache.insert("x", 1);
cache.insert("y", 10);
cache.insert("z", 100);
let dump: Dump<&str, usize> = Dump::from(cache);
assert_eq!("Dump { capacity: 10, data: [(\"x\", 1), (\"y\", 10), (\"z\", 100)] }", format!("{:?}", dump));
let restore: Cache<&str, usize> = Cache::from(dump);
assert_eq!(10, restore.capacity());
assert_eq!("[x: 1, y: 10, z: 100]", format!("{}", &restore));
Fields§
§capacity: usize
§data: Vec<(K, V)>
Trait Implementations§
Source§impl<'de, K, V> Deserialize<'de> for Dump<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
impl<'de, K, V> Deserialize<'de> for Dump<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
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<K, V> Eq for Dump<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Dump<K, V>
impl<K, V> RefUnwindSafe for Dump<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Dump<K, V>
impl<K, V> Sync for Dump<K, V>
impl<K, V> Unpin for Dump<K, V>
impl<K, V> UnwindSafe for Dump<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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