pub struct AironeDb<T, SaveMode = AutoSave>where
T: InnerStruct,
SaveMode: SaveModeExt,{ /* private fields */ }
Implementations§
source§impl<T: InnerStruct, SaveMode: SaveModeExt> AironeDb<T, SaveMode>
impl<T: InnerStruct, SaveMode: SaveModeExt> AironeDb<T, SaveMode>
pub fn new() -> Result<Self, Error>
pub fn new_with_custom_name(custom_name: &str) -> Result<Self, Error>
pub fn get_all(&self) -> &[T]
pub fn get(&self, index: usize) -> Option<&T>
sourcepub fn get_mut(&mut self, index: usize) -> Option<WriteProxy<'_, T, SaveMode>>
pub fn get_mut(&mut self, index: usize) -> Option<WriteProxy<'_, T, SaveMode>>
Mutably access the element at the specified index
pub fn set_buffer_mode(&mut self, mode: BufferMode) -> Result<(), Error>
pub fn iter(&self) -> impl Iterator<Item = &T>
sourcepub fn set_save_mode<NewSaveMode: SaveModeExt>(
self
) -> Result<AironeDb<T, NewSaveMode>, Error>
pub fn set_save_mode<NewSaveMode: SaveModeExt>( self ) -> Result<AironeDb<T, NewSaveMode>, Error>
Change the SaveMode to the provided value
For example, you can convert a db to ManualSave or AutoSave mode. While changing mode, any pending change is written to disk and you won’t be able to rollback.
source§impl<T: InnerStruct> AironeDb<T, AutoSave>
impl<T: InnerStruct> AironeDb<T, AutoSave>
sourcepub fn insert(&mut self, index: usize, element: T) -> Result<(), Error>
pub fn insert(&mut self, index: usize, element: T) -> Result<(), Error>
Inserts an element at position index
within the vector, shifting all
elements after it to the right.
§Panics
Panics if index > len
.
sourcepub fn push(&mut self, element: T) -> Result<(), Error>
pub fn push(&mut self, element: T) -> Result<(), Error>
Adds a new element to the end of the list
sourcepub fn pop(&mut self) -> Result<Option<T>, Error>
pub fn pop(&mut self) -> Result<Option<T>, Error>
Removes the last element of the list and returns it if existing
sourcepub fn extend(&mut self, iter: impl Iterator<Item = T>) -> Result<(), Error>
pub fn extend(&mut self, iter: impl Iterator<Item = T>) -> Result<(), Error>
Adds the elements of an iterator to the end of the list.
sourcepub fn append(&mut self, other: &mut Vec<T>) -> Result<(), Error>
pub fn append(&mut self, other: &mut Vec<T>) -> Result<(), Error>
Adds multiple elements to the end of the list, automatically reducing the number of syscalls to write them to disk
Works similar to https://doc.rust-lang.org/std/vec/struct.Vec.html#method.append
sourcepub fn remove(&mut self, index: usize) -> Result<T, Error>
pub fn remove(&mut self, index: usize) -> Result<T, Error>
Removes and returns the element at index
. Panics if out of bounds.
sourcepub fn drain(
&mut self,
range: impl RangeBounds<usize>
) -> Result<impl Iterator<Item = T>, Error>
pub fn drain( &mut self, range: impl RangeBounds<usize> ) -> Result<impl Iterator<Item = T>, Error>
Removes the specified range in bulk and returns an iterator over the removed elements
sourcepub fn retain<F: Fn(&T) -> bool>(&mut self, f: F) -> Result<(), Error>
pub fn retain<F: Fn(&T) -> bool>(&mut self, f: F) -> Result<(), Error>
Keeps only the elements that match the predicate
Removes all the elements that do not satisfy the condition
pub fn set<V: SerializableField>( &mut self, index: usize, fieldname: &'static str, value: V ) -> Result<(), Error>
source§impl<T: InnerStruct> AironeDb<T, ManualSave>
impl<T: InnerStruct> AironeDb<T, ManualSave>
sourcepub fn insert(&mut self, index: usize, element: T)
pub fn insert(&mut self, index: usize, element: T)
Inserts an element at position index
within the vector, shifting all
elements after it to the right.
§Panics
Panics if index > len
.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes the last element of the list and returns it if existing
sourcepub fn extend(&mut self, iter: impl Iterator<Item = T>)
pub fn extend(&mut self, iter: impl Iterator<Item = T>)
Adds the elements of an iterator to the end of the list.
sourcepub fn append(&mut self, other: &mut Vec<T>)
pub fn append(&mut self, other: &mut Vec<T>)
Adds multiple elements to the end of the list, automatically reducing the number of syscalls to write them to disk
Works similar to https://doc.rust-lang.org/std/vec/struct.Vec.html#method.append
sourcepub fn remove(&mut self, index: usize) -> T
pub fn remove(&mut self, index: usize) -> T
Removes and returns the element at index
. Panics if out of bounds.
sourcepub fn drain(
&mut self,
range: impl RangeBounds<usize>
) -> impl Iterator<Item = T>
pub fn drain( &mut self, range: impl RangeBounds<usize> ) -> impl Iterator<Item = T>
Removes the specified range in bulk and returns an iterator over the removed elements
sourcepub fn retain<F: Fn(&T) -> bool>(&mut self, f: F)
pub fn retain<F: Fn(&T) -> bool>(&mut self, f: F)
Keeps only the elements that match the predicate
Removes all the elements that do not satisfy the condition