Struct light_magic::table::Table
source · pub struct Table<K, V>where
K: Ord + FromStr + Display,
<K as FromStr>::Err: Display,
V: Serialize + for<'a> Deserialize<'a>,{ /* private fields */ }Expand description
Represents a database table utilizing a BTreeMap for underlying data storage.
Offers enhanced methods for manipulating records, including add, edit, delete, get, and search.
Implementations§
source§impl<K, V> Table<K, V>
impl<K, V> Table<K, V>
sourcepub fn add(&mut self, value: V) -> Option<V>
pub fn add(&mut self, value: V) -> Option<V>
Adds an entry to the table, returns the value or None if the addition failed
sourcepub fn get(&self, key: &K) -> Option<V>
pub fn get(&self, key: &K) -> Option<V>
Gets an entry from the table, returns the value or None if it couldn’t find the data
sourcepub fn edit(&mut self, key: &K, new_value: V) -> Option<V>
pub fn edit(&mut self, key: &K, new_value: V) -> Option<V>
Edits an entry in the table, returns the new_value or None if the editing failed
sourcepub fn delete(&mut self, key: &K) -> Option<V>
pub fn delete(&mut self, key: &K) -> Option<V>
Deletes an entry from the table, returns the value or None if the deletion failed
pub fn values(&self) -> Values<'_, K, V>
Trait Implementations§
source§impl<'de, K, V> Deserialize<'de> for Table<K, V>
impl<'de, K, V> Deserialize<'de> for Table<K, V>
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
Auto Trait Implementations§
impl<K, V> Freeze for Table<K, V>
impl<K, V> RefUnwindSafe for Table<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Table<K, V>
impl<K, V> Sync for Table<K, V>
impl<K, V> Unpin for Table<K, V>
impl<K, V> UnwindSafe for Table<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
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