pub struct TdfMap<K: MapKey, V: Codec> { /* private fields */ }
Expand description
Structure for Tdf maps these are maps that are created from two Vec so they retain insertion order but are slow for lookups. This implementation guarantees the lengths of both lists are the same
Implementations
sourceimpl<K: MapKey, V: Codec> TdfMap<K, V>
impl<K: MapKey, V: Codec> TdfMap<K, V>
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new empty TdfMap sized to account for the provided capacity of contents
sourcepub fn insert(&mut self, key: impl Into<K>, value: impl Into<V>)
pub fn insert(&mut self, key: impl Into<K>, value: impl Into<V>)
Insert a new entry into the map
sourcepub fn insert_multiple(&mut self, entries: impl IntoIterator<Item = (K, V)>)
pub fn insert_multiple(&mut self, entries: impl IntoIterator<Item = (K, V)>)
Inserts multiple entries from an iterable value (i.e. Vec / slice of key value tuples)
sourcepub fn remove(&mut self, key: &K) -> Option<(K, V)>
pub fn remove(&mut self, key: &K) -> Option<(K, V)>
Removes a value by its key and returns the entry that was present at that position.
sourcepub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq,
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq,
Returns the value stored at the provided key if its present or None.
Trait Implementations
sourceimpl<K: MapKey, V: Codec> Codec for TdfMap<K, V>
impl<K: MapKey, V: Codec> Codec for TdfMap<K, V>
sourcefn encode(&self, output: &mut Vec<u8>)
fn encode(&self, output: &mut Vec<u8>)
Function for implementing encoding of Self to the
provided vec of bytes Read more
sourcefn decode(reader: &mut Reader<'_>) -> CodecResult<Self>
fn decode(reader: &mut Reader<'_>) -> CodecResult<Self>
Function for implementing decoding of Self from
the provided Reader. Will return None if self
cannot be decoded Read more
sourcefn value_type() -> ValueType
fn value_type() -> ValueType
Optional additional specifier for Tdf types that
tells which type this is Read more
sourcefn skip(reader: &mut Reader<'_>) -> CodecResult<()>
fn skip(reader: &mut Reader<'_>) -> CodecResult<()>
Function to provide functionality for skipping this
data type (e.g. read the bytes without using them) Read more
sourcefn encode_bytes(&self) -> Vec<u8>
fn encode_bytes(&self) -> Vec<u8>
Shortcut function for encoding self directly to
a Vec of bytes Read more
sourceimpl<K: MapKey, V: Codec> From<HashMap<K, V, RandomState>> for TdfMap<K, V>
impl<K: MapKey, V: Codec> From<HashMap<K, V, RandomState>> for TdfMap<K, V>
Implementation for converting a HashMap to a TdfMap by taking all its keys and values and building lists for the TdfMap
sourceimpl<'a, K: MapKey, V: Codec> IntoIterator for &'a TdfMap<K, V>
impl<'a, K: MapKey, V: Codec> IntoIterator for &'a TdfMap<K, V>
Auto Trait Implementations
impl<K, V> RefUnwindSafe for TdfMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for TdfMap<K, V>where
K: Send,
V: Send,
impl<K, V> Sync for TdfMap<K, V>where
K: Sync,
V: Sync,
impl<K, V> Unpin for TdfMap<K, V>where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for TdfMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more