pub struct CollectionTree<Item: Record> { /* private fields */ }Implementations§
Source§impl<Item> CollectionTree<Item>
impl<Item> CollectionTree<Item>
Sourcepub fn upsert(
&self,
id: impl Borrow<Item::SelfId> + Debug,
item: &Item,
) -> DbResult<Option<Item>>
pub fn upsert( &self, id: impl Borrow<Item::SelfId> + Debug, item: &Item, ) -> DbResult<Option<Item>>
Insert or update value by id. Return old value if exist
Sourcepub fn upsert_fn<F, Ret>(
&self,
id: impl Borrow<Item::SelfId> + Debug,
f: F,
) -> DbResult<(Option<Item>, Ret)>
pub fn upsert_fn<F, Ret>( &self, id: impl Borrow<Item::SelfId> + Debug, f: F, ) -> DbResult<(Option<Item>, Ret)>
Update, create or delete value by id with Fn. Can call closure multiple times.
Return new value and closure result
Sourcepub fn update_fn<F>(
&self,
id: impl Borrow<Item::SelfId> + Debug,
f: F,
) -> DbResult<Item>
pub fn update_fn<F>( &self, id: impl Borrow<Item::SelfId> + Debug, f: F, ) -> DbResult<Item>
Update item with closure if exist, return new value. Tried only once.
pub fn updater(&self, id: Item::SelfId) -> DbResult<Updater<Item>>where
Item: Clone,
Sourcepub fn apply_updater(&self, updater: Updater<Item>) -> DbResult<Entry<Item>>
pub fn apply_updater(&self, updater: Updater<Item>) -> DbResult<Entry<Item>>
Tried only once.
Sourcepub fn change_status(
&self,
old_id: &Item::SelfId,
new_id: &Item::SelfId,
) -> DbResult<()>
👎Deprecated
pub fn change_status( &self, old_id: &Item::SelfId, new_id: &Item::SelfId, ) -> DbResult<()>
change status in item key with closure, if key not exist, does nothing. not use for change id!
Sourcepub fn remove(
&self,
id: impl Borrow<Item::SelfId> + Debug,
) -> DbResult<Option<Item>>
pub fn remove( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>
permanently remove item. Return old value or None if not exist
pub fn remove_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>
Source§impl<Item> CollectionTree<Item>
impl<Item> CollectionTree<Item>
Sourcepub fn get(
&self,
id: impl Borrow<Item::SelfId> + Debug,
) -> DbResult<Option<Item>>
pub fn get( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>
get value by id
pub fn get_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>
Sourcepub fn get_or_err(
&self,
id: impl Borrow<Item::SelfId> + Debug,
) -> DbResult<Item>
pub fn get_or_err( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Item>
get value by id or return not found
Sourcepub fn contains(&self, id: impl Borrow<Item::SelfId> + Debug) -> DbResult<bool>
pub fn contains(&self, id: impl Borrow<Item::SelfId> + Debug) -> DbResult<bool>
check exist by id
pub fn contains_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<bool>
Sourcepub fn iter(&self) -> IterCollection<Entry<Item>>
pub fn iter(&self) -> IterCollection<Entry<Item>>
get iterator for collection
Sourcepub fn scan_prefix<P>(&self, prefix: P) -> IterCollection<Entry<Item>>
pub fn scan_prefix<P>(&self, prefix: P) -> IterCollection<Entry<Item>>
get iterator by prefix for collection
Sourcepub fn range_iter<K, R>(&self, range: R) -> IterCollection<Entry<Item>>
pub fn range_iter<K, R>(&self, range: R) -> IterCollection<Entry<Item>>
get iterator by range for collection
Sourcepub fn try_range_iter<K, R>(
&self,
range: R,
) -> impl DoubleEndedIterator<Item = DbResult<Entry<Item>>> + use<K, R, Item>
pub fn try_range_iter<K, R>( &self, range: R, ) -> impl DoubleEndedIterator<Item = DbResult<Entry<Item>>> + use<K, R, Item>
get iterator by range for collection if item error, return Error
Sourcepub fn try_range_iter_with_raw<K, R>(
&self,
range: R,
) -> impl DoubleEndedIterator<Item = DbResult<ItemWithRaw<Item>>> + use<K, R, Item>
pub fn try_range_iter_with_raw<K, R>( &self, range: R, ) -> impl DoubleEndedIterator<Item = DbResult<ItemWithRaw<Item>>> + use<K, R, Item>
get iterator by range for collection if item error, return Error
Sourcepub fn iter_keys<P>(
&self,
prefix: P,
) -> impl DoubleEndedIterator<Item = Item::SelfId> + use<P, Item>
pub fn iter_keys<P>( &self, prefix: P, ) -> impl DoubleEndedIterator<Item = Item::SelfId> + use<P, Item>
iter without deserialize value
Sourcepub fn par_iter(
&self,
seq: Option<u64>,
) -> DbResult<MaybeParIter<impl IndexedParallelIterator<Item = (Iter, Self)> + '_, Iter>>
pub fn par_iter( &self, seq: Option<u64>, ) -> DbResult<MaybeParIter<impl IndexedParallelIterator<Item = (Iter, Self)> + '_, Iter>>
Split collection into groups for parallel processing
used rayon for parallelism
pub fn cast_slice<K: AsRef<[u8]>>( &self, id: K, ) -> DbResult<Option<BytesAsValSlice<InlineArray, Item>>>
Source§impl<Item> CollectionTree<Item>
impl<Item> CollectionTree<Item>
Methods from Deref<Target = RawTree>§
pub fn checksum(&self) -> u32
pub fn is_empty(&self) -> bool
pub fn count(&self) -> u64
pub fn subscribe(&self) -> Receiver<ChangeEvent>
pub fn hashpoints(&self) -> CheckSumVec
pub fn scan_group( &self, group: u32, ) -> impl DoubleEndedIterator<Item = KeyValue> + use<>
pub fn recalcucate_hash(&self) -> u64
Sourcepub fn get(&self, id: &[u8]) -> DbResult<Option<Vec<u8>>>
pub fn get(&self, id: &[u8]) -> DbResult<Option<Vec<u8>>>
return slice with [key + value] bytes
pub fn range( &self, range: (Bound<&[u8]>, Bound<&[u8]>), ) -> Box<dyn DoubleEndedIterator<Item = KeyValue>>
pub fn next_id(&self) -> DbResult<u64>
pub fn apply_event(&self, event: ChangeEvent) -> DbResult<()>
pub fn apply_batch( &self, iter: impl Iterator<Item = (ByteValue, Option<ByteValue>)>, ) -> DbResult<()>
Trait Implementations§
Source§impl<Item: Record> Clone for CollectionTree<Item>
impl<Item: Record> Clone for CollectionTree<Item>
Source§impl<Item: Record> Debug for CollectionTree<Item>
impl<Item: Record> Debug for CollectionTree<Item>
Source§impl<Item: Record> Deref for CollectionTree<Item>
impl<Item: Record> Deref for CollectionTree<Item>
Source§impl<Item: Record> From<CollectionTree<Item>> for RawTree
impl<Item: Record> From<CollectionTree<Item>> for RawTree
Source§fn from(value: CollectionTree<Item>) -> Self
fn from(value: CollectionTree<Item>) -> Self
Auto Trait Implementations§
impl<Item> !Freeze for CollectionTree<Item>
impl<Item> !RefUnwindSafe for CollectionTree<Item>
impl<Item> Send for CollectionTree<Item>
impl<Item> !Sync for CollectionTree<Item>
impl<Item> Unpin for CollectionTree<Item>
impl<Item> !UnwindSafe for CollectionTree<Item>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more