pub struct Handles<'store, T>where
T: Storable,{ /* private fields */ }Expand description
Holds a collection of items. The collection may be either owned or borrowed from the store (usually from a reverse index).
The items in the collection by definition refer to the AnnotationStore, as
internally the collection only keeps fully qualified handles and a reference to the store.
This structure is produced via the ToHandles trait that is implemented
for all iterators over ResultItem<T>.
Implementations§
source§impl<'store, T> Handles<'store, T>where
T: Storable,
impl<'store, T> Handles<'store, T>where
T: Storable,
sourcepub fn returns_sorted(&self) -> bool
pub fn returns_sorted(&self) -> bool
Are the items in this collection sorted (chronologically, i.e. by handle) or not?
sourcepub fn store(&self) -> &'store AnnotationStore
pub fn store(&self) -> &'store AnnotationStore
Returns a reference to the underlying AnnotationStore.
sourcepub fn new(
array: Cow<'store, [T::FullHandleType]>,
sorted: bool,
store: &'store AnnotationStore
) -> Self
pub fn new( array: Cow<'store, [T::FullHandleType]>, sorted: bool, store: &'store AnnotationStore ) -> Self
Low-level method to instantiate annotations from an existing vector of handles (either owned or borrowed from the store). Warning: Use of this function is dangerous and discouraged in most cases as there is no validity check on the handles you pass!
The safe option is to convert from an iterator of ResultItem<T> to Handles<T>, then use ToHandles::to_handles() on that
sourcepub fn new_empty(store: &'store AnnotationStore) -> Self
pub fn new_empty(store: &'store AnnotationStore) -> Self
Returns a new empty handles collection
sourcepub fn from_iter(
iter: impl Iterator<Item = T::FullHandleType>,
store: &'store AnnotationStore
) -> Self
pub fn from_iter( iter: impl Iterator<Item = T::FullHandleType>, store: &'store AnnotationStore ) -> Self
Create a new handles collection from an iterator handles Warning: Use of this function is dangerous and discouraged in most cases as there is no validity check on the handles you pass!
If you want to convert from an iterator of ResultItem<T> to Handles<T>, then use ToHandles::to_handles() on that
sourcepub fn take(self) -> Cow<'store, [T::FullHandleType]>where
Self: Sized,
pub fn take(self) -> Cow<'store, [T::FullHandleType]>where
Self: Sized,
Low-level method to take out the underlying vector of handles
sourcepub fn get(&self, index: usize) -> Option<T::FullHandleType>
pub fn get(&self, index: usize) -> Option<T::FullHandleType>
Returns the number of items in this collection.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns a boolean indicating whether the collection is empty or not.
sourcepub fn contains(&self, handle: &T::FullHandleType) -> bool
pub fn contains(&self, handle: &T::FullHandleType) -> bool
Tests if the collection contains a specific element
sourcepub fn position(&self, handle: &T::FullHandleType) -> Option<usize>
pub fn position(&self, handle: &T::FullHandleType) -> Option<usize>
Tests if the collection contains a specific element and returns the index
sourcepub fn iter<'a>(&'a self) -> HandlesIter<'a, T>
pub fn iter<'a>(&'a self) -> HandlesIter<'a, T>
Returns an iterator over the low-level handles in this collection
If you want to iterate over the actual items (ResultItem<T>), then use Self::items() instead.
sourcepub fn items<'a>(&'a self) -> FromHandles<'store, T, HandlesIter<'store, T>> ⓘwhere
'a: 'store,
pub fn items<'a>(&'a self) -> FromHandles<'store, T, HandlesIter<'store, T>> ⓘwhere
'a: 'store,
Returns an iterator over the high-level items in this collection
If you want to iterate over the low-level handles, then use Self::iter() instead.
sourcepub fn union(&mut self, other: &Self)
pub fn union(&mut self, other: &Self)
Computes the union between two collections, retains order and ensures there are no duplicates Modifies the collection in-place to accommodate the other
sourcepub fn intersection(&mut self, other: &Self)
pub fn intersection(&mut self, other: &Self)
Computes the intersection between two collections, retains order Modifies the collection in-place to match the other
sourcepub fn contains_subset(&self, subset: &Self) -> bool
pub fn contains_subset(&self, subset: &Self) -> bool
Checks if the collections contains another (need not be contingent)
sourcepub fn sort(&mut self)
pub fn sort(&mut self)
Sorts the collection in chronological order (i.e. the handles are sorted) Note that this is NOT the same as textual order.
sourcepub fn add(&mut self, item: T::FullHandleType)
pub fn add(&mut self, item: T::FullHandleType)
Adds an item to the collection, this checks for duplicates and respects existing sorting (if any),
so this comes with performance overhead. Use [Self.union()] to add multiple items at once more efficiently.