Skip to main content

List

Struct List 

Source
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>

Source

pub async fn new(path: impl AsRef<Path>) -> TokioResult<Self>

Create a new List object located at path.

Source

pub fn exists(&self, key: &K) -> bool

Check whether the key exists.

Source

pub async fn size(&self) -> TokioResult<usize>

Size of the list.

Source

pub async fn list(&mut self) -> TokioResult<Vec<T>>

List all records as a vector.

Source

pub async fn map(&mut self) -> TokioResult<HashMap<K, T>>

Mapping of all records by key.

Source

pub async fn detail(&mut self, key: &K) -> TokioResult<T>

Get record by key.

Source

pub async fn add(&mut self, rec: &T) -> TokioResult<()>

Add a new record.

Source

pub async fn remove(&mut self, key: &K) -> TokioResult<()>

Remove the record by key.

Source

pub async fn modify(&mut self, key: &K, rec: &T) -> TokioResult<()>

Modify 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>
where T: Send, K: Send,

§

impl<T, K> Sync for List<T, K>
where T: Sync, K: Sync,

§

impl<T, K> Unpin for List<T, K>
where T: Unpin, K: Unpin,

§

impl<T, K> UnsafeUnpin for List<T, K>

§

impl<T, K> !UnwindSafe for List<T, K>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.