pub struct List<T, K> { /* private fields */ }Expand description
List implements methods to work with small lists stored as a Col object.
List keeps index map in the memory to reduce the access to the data
in the file, so if there are too many records, List object may be
consuming. The main purpose of List the is inner data management between
files, data types, structeres and so on in the DBSM.
Implementations§
Source§impl<K: Clone + Eq + Hash, T: Clone + ListKeyTrait<K>> List<T, K>
impl<K: Clone + Eq + Hash, T: Clone + ListKeyTrait<K>> List<T, K>
Sourcepub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>
pub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>
Create a new List object located at path.
Sourcepub async fn size(&self) -> TokioResult<usize>
pub async fn size(&self) -> TokioResult<usize>
Size of the list.
Sourcepub async fn list(&mut self) -> TokioResult<Vec<T>>
pub async fn list(&mut self) -> TokioResult<Vec<T>>
List all records as a vector.
Sourcepub async fn map(&mut self) -> TokioResult<HashMap<K, T>>
pub async fn map(&mut self) -> TokioResult<HashMap<K, T>>
Mapping of all records by key.
Sourcepub async fn detail(&mut self, key: &K) -> TokioResult<T>
pub async fn detail(&mut self, key: &K) -> TokioResult<T>
Get record by key.
Sourcepub async fn add(&mut self, rec: &T) -> TokioResult<()>
pub async fn add(&mut self, rec: &T) -> TokioResult<()>
Add a new record.
Sourcepub async fn remove(&mut self, key: &K) -> TokioResult<()>
pub async fn remove(&mut self, key: &K) -> TokioResult<()>
Remove the record by key.
Auto Trait Implementations§
impl<T, K> !Freeze for List<T, K>
impl<T, K> !RefUnwindSafe for List<T, K>
impl<T, K> Send for List<T, K>
impl<T, K> Sync for List<T, K>
impl<T, K> Unpin for List<T, K>
impl<T, K> UnsafeUnpin for List<T, K>
impl<T, K> !UnwindSafe for List<T, K>
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