Struct stam::Handles

source ·
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,

source

pub fn returns_sorted(&self) -> bool

Are the items in this collection sorted (chronologically, i.e. by handle) or not?

source

pub fn store(&self) -> &'store AnnotationStore

Returns a reference to the underlying AnnotationStore.

source

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

source

pub fn new_empty(store: &'store AnnotationStore) -> Self

Returns a new empty handles collection

source

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

source

pub fn take(self) -> Cow<'store, [T::FullHandleType]>
where Self: Sized,

Low-level method to take out the underlying vector of handles

source

pub fn len(&self) -> usize

Returns the number of items in this collection.

source

pub fn get(&self, index: usize) -> Option<T::FullHandleType>

Returns the number of items in this collection.

source

pub fn is_empty(&self) -> bool

Returns a boolean indicating whether the collection is empty or not.

source

pub fn contains(&self, handle: &T::FullHandleType) -> bool

Tests if the collection contains a specific element

source

pub fn position(&self, handle: &T::FullHandleType) -> Option<usize>

Tests if the collection contains a specific element and returns the index

source

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.

source

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.

source

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

source

pub fn intersection(&mut self, other: &Self)

Computes the intersection between two collections, retains order Modifies the collection in-place to match the other

source

pub fn contains_subset(&self, subset: &Self) -> bool

Checks if the collections contains another (need not be contingent)

source

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.

source

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.

Trait Implementations§

source§

impl<'store, T> Clone for Handles<'store, T>

source§

fn clone(&self) -> Handles<'store, T>

Returns a copy 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<'store, T> Debug for Handles<'store, T>
where T: Storable,

source§

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

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

impl<'store, T> IntoIterator for Handles<'store, T>
where T: Storable,

§

type Item = <T as Storable>::FullHandleType

The type of the elements being iterated over.
§

type IntoIter = OwnedHandlesIter<'store, T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'store, T> RefUnwindSafe for Handles<'store, T>

§

impl<'store, T> Send for Handles<'store, T>
where <T as Storable>::FullHandleType: Sync + Send,

§

impl<'store, T> Sync for Handles<'store, T>
where <T as Storable>::FullHandleType: Sync,

§

impl<'store, T> Unpin for Handles<'store, T>
where <T as Storable>::FullHandleType: Unpin,

§

impl<'store, T> UnwindSafe for Handles<'store, T>

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

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

§

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

§

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.
§

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

§

fn vzip(self) -> V