#![deny(missing_docs)] //! An implementation of a key/value store use std::collections::HashMap; #[derive(Debug, Default)] /// A key/value store pub struct KvStore { store: HashMap, } impl KvStore { /// Create a new store pub fn new() -> Self { KvStore { store: HashMap::new(), } } /// Set a key/value pair pub fn set(&mut self, key: String, value: String) { self.store.insert(key, value); } /// Get the value at the specified key pub fn get(&mut self, key: String) -> Option { match self.store.get(&key) { Some(s) => Some(s.to_owned()), None => None, } } /// Remove the value at the specified key pub fn remove(&mut self, key: String) { self.store.remove(&key); } }