CollectionTree

Struct CollectionTree 

Source
pub struct CollectionTree<Item: Record> { /* private fields */ }

Implementations§

Source§

impl<Item> CollectionTree<Item>
where Item: Record<Value = InlineArray> + Debug,

Source

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

Source

pub fn upsert_fn<F, Ret>( &self, id: impl Borrow<Item::SelfId> + Debug, f: F, ) -> DbResult<(Option<Item>, Ret)>
where F: Fn(Option<Item>) -> (Option<Item>, Ret), Item: Clone, Ret: Debug,

Update, create or delete value by id with Fn. Can call closure multiple times.

Return new value and closure result

Source

pub fn update_fn<F>( &self, id: impl Borrow<Item::SelfId> + Debug, f: F, ) -> DbResult<Item>
where F: FnOnce(Item) -> DbResult<Item>, Item: Clone,

Update item with closure if exist, return new value. Tried only once.

Source

pub fn updater(&self, id: Item::SelfId) -> DbResult<Updater<Item>>
where Item: Clone,

Source

pub fn apply_updater(&self, updater: Updater<Item>) -> DbResult<Entry<Item>>

Tried only once.

Source

pub fn change_status( &self, old_id: &Item::SelfId, new_id: &Item::SelfId, ) -> DbResult<()>

👎Deprecated

change status in item key with closure, if key not exist, does nothing. not use for change id!

Source

pub fn remove( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>

permanently remove item. Return old value or None if not exist

Source

pub fn remove_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>

👎Deprecated
Source

pub fn soft_remove( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>

Remove item to other (‘removed’) tree. Return old value or None if not exist

Source§

impl<Item> CollectionTree<Item>
where Item: Record<Value = InlineArray> + Debug,

Source

pub fn get( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>

get value by id

Source

pub fn get_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Option<Item>>

👎Deprecated
Source

pub fn get_or_err( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<Item>

get value by id or return not found

Source

pub fn contains(&self, id: impl Borrow<Item::SelfId> + Debug) -> DbResult<bool>

check exist by id

Source

pub fn contains_item( &self, id: impl Borrow<Item::SelfId> + Debug, ) -> DbResult<bool>

👎Deprecated
Source

pub fn iter(&self) -> IterCollection<Entry<Item>>

get iterator for collection

Source

pub fn scan_prefix<P>(&self, prefix: P) -> IterCollection<Entry<Item>>
where P: AsRef<[u8]> + Debug,

get iterator by prefix for collection

Source

pub fn range_iter<K, R>(&self, range: R) -> IterCollection<Entry<Item>>
where K: AsRef<[u8]>, R: RangeBounds<K> + Debug,

get iterator by range for collection

Source

pub fn try_range_iter<K, R>( &self, range: R, ) -> impl DoubleEndedIterator<Item = DbResult<Entry<Item>>> + use<K, R, Item>
where K: AsRef<[u8]>, R: RangeBounds<K> + Debug,

get iterator by range for collection if item error, return Error

Source

pub fn try_range_iter_with_raw<K, R>( &self, range: R, ) -> impl DoubleEndedIterator<Item = DbResult<ItemWithRaw<Item>>> + use<K, R, Item>
where K: AsRef<[u8]>, R: RangeBounds<K> + Debug,

get iterator by range for collection if item error, return Error

Source

pub fn iter_keys<P>( &self, prefix: P, ) -> impl DoubleEndedIterator<Item = Item::SelfId> + use<P, Item>
where P: AsRef<[u8]> + Debug,

iter without deserialize value

Source

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

Source

pub fn cast_slice<K: AsRef<[u8]>>( &self, id: K, ) -> DbResult<Option<BytesAsValSlice<InlineArray, Item>>>

Source§

impl<Item> CollectionTree<Item>
where Item: Record<Value = InlineArray> + Debug,

Source

pub fn open(db: Database) -> Self

Source

pub fn open_tree(db: Database) -> Self

👎Deprecated
Source

pub fn with_name(db: Database, name: &str) -> Self

Source

pub fn builder(db: Database) -> CollectionBuilder<Item>

Source

pub fn raw(&self) -> &RawTree

Source

pub fn close(self)

Methods from Deref<Target = RawTree>§

Source

pub fn checksum(&self) -> u32

Source

pub fn is_empty(&self) -> bool

Source

pub fn count(&self) -> u64

Source

pub fn subscribe(&self) -> Receiver<ChangeEvent>

Source

pub fn hashpoints(&self) -> CheckSumVec

Source

pub fn scan_group( &self, group: u32, ) -> impl DoubleEndedIterator<Item = KeyValue> + use<>

Source

pub fn recalcucate_hash(&self) -> u64

Source

pub fn close(&self)

save seq number, type hash, version to db, flush tree

Source

pub fn get(&self, id: &[u8]) -> DbResult<Option<Vec<u8>>>

return slice with [key + value] bytes

Source

pub fn range( &self, range: (Bound<&[u8]>, Bound<&[u8]>), ) -> Box<dyn DoubleEndedIterator<Item = KeyValue>>

Source

pub fn next_id(&self) -> DbResult<u64>

Source

pub fn apply_event(&self, event: ChangeEvent) -> DbResult<()>

Source

pub fn apply_batch( &self, iter: impl Iterator<Item = (ByteValue, Option<ByteValue>)>, ) -> DbResult<()>

Trait Implementations§

Source§

impl<Item: Record> Clone for CollectionTree<Item>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Item: Record> Debug for CollectionTree<Item>
where Arc<EventHandlers<Item>>: Debug,

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Item: Record> Deref for CollectionTree<Item>

Source§

type Target = RawTree

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<Item: Record> From<CollectionTree<Item>> for RawTree

Source§

fn from(value: CollectionTree<Item>) -> Self

Converts to this type from the input type.

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more