Enum stam::Selector

source ·
pub enum Selector {
Show 13 variants ResourceSelector(TextResourceHandle), AnnotationSelector(AnnotationHandle, Option<Offset>), TextSelector(TextResourceHandle, Offset), DataSetSelector(AnnotationDataSetHandle), MultiSelector(Vec<Selector>), CompositeSelector(Vec<Selector>), DirectionalSelector(Vec<Selector>), InternalTextSelector { resource: TextResourceHandle, textselection: TextSelectionHandle, }, InternalAnnotationTextSelector { annotation: AnnotationHandle, resource: TextResourceHandle, textselection: TextSelectionHandle, }, InternalRangedTextSelector { resource: TextResourceHandle, begin: TextSelectionHandle, end: TextSelectionHandle, }, InternalRangedAnnotationSelector { begin: AnnotationHandle, end: AnnotationHandle, }, InternalRangedResourceSelector { begin: TextResourceHandle, end: TextResourceHandle, }, InternalRangedDataSetSelector { begin: AnnotationDataSetHandle, end: AnnotationDataSetHandle, },
}
Expand description

A Selector identifies the target of an annotation and the part of the target that the annotation applies to. Selectors can be considered the labelled edges of the graph model, tying all nodes together. There are multiple types of selectors, all captured in this enum.

You usually do not instantiate these directly but via SelectorBuilder. In searching, you also don’t need direct access to this structure as the various search methods on AnnotationStore will resolve the selectors transparently.

Variants§

§

ResourceSelector(TextResourceHandle)

Refers to a TextResource as a whole (as opposed to a text fragment inside it), as owned by an AnnotationStore. Annotations using this selector can be considered metadata of a text

§

AnnotationSelector(AnnotationHandle, Option<Offset>)

Refers to an Annotation (as owned by the AnnotationStore) and optionally a relative text selection offset in it

§

TextSelector(TextResourceHandle, Offset)

Refers to the TextResource (as owned by the AnnotationStore) an an offset in it

§

DataSetSelector(AnnotationDataSetHandle)

Refers to an crate::AnnotationDataSet as owned by an [`AnnotationStore’] Annotations using this selector can be considered metadata.

§

MultiSelector(Vec<Selector>)

A selector that combines selectors, where the annotation applies to each target individually. without any relation between the different targets. Leaving one out or adding one MUST NOT affect the interpretation of any of the others nor of the whole. This is a way to express multiple annotations as one, a more condensed representation. This selector SHOULD be used sparingly in your modelling, as it is generally RECOMMENDED to simply use multiple [Annotation'] instances instead. In STAM, even with multiple annotations, you benefit from the fact that multiple annotations may share the same [AnnotationData`], and can therefore easily retrieve all annotations that share particular data.

§

CompositeSelector(Vec<Selector>)

A selector that consists of multiple other selectors, used to select more complex targets that transcend the idea of a single simple selection. This MUST be interpreted as the annotation applying equally to the conjunction as a whole, its parts being inter-dependent and for any of them it goes that they MUST NOT be omitted for the annotation to make sense. The interpretation of the whole relies on all its parts. Note that the order of the selectors is not significant (use a Self::DirectionalSelector instead if they are). When there is no dependency relation between the selectors, you MUST simply use multiple Annotation instances or a Self::MultiSelector instead. When grouping things into a set, do use this [`Self::CompositeSelector’], as the set as a whole is considered a composite entity.

§

DirectionalSelector(Vec<Selector>)

Combines selectors and expresseds a direction between two or more selectors in the exact order specified (from -> to)

§

InternalTextSelector

Fields

§textselection: TextSelectionHandle

Internal selector pointing directly to a TextSelection, exposed as TextSelector to the outside world

§

InternalAnnotationTextSelector

Fields

§annotation: AnnotationHandle
§textselection: TextSelectionHandle

Internal selector pointing directly to a TextSelection and an Annotation, exposed as AnnotationSelector to the outside world This can only be used for annotations that select the entire text of the underlying annotation (no subslices)

§

InternalRangedTextSelector

Fields

§begin: TextSelectionHandle
§end: TextSelectionHandle

Internal ranged selector, used as subselector for MultiSelector/CompositeSelector/DirectionalSelector Conserved memory by pointing to a internal ID range

§

InternalRangedAnnotationSelector

Internal ranged selector, used as subselector for MultiSelector/CompositeSelector/DirectionalSelector Conserved memory by pointing to a internal ID range

§

InternalRangedResourceSelector

Internal ranged selector, used as subselector for MultiSelector/CompositeSelector/DirectionalSelector Conserved memory by pointing to a internal ID range

§

InternalRangedDataSetSelector

Internal ranged selector, used as subselector for MultiSelector/CompositeSelector/DirectionalSelector Conserved memory by pointing to a internal ID range

Implementations§

source§

impl Selector

source

pub fn kind(&self) -> SelectorKind

Returns a SelectorKind

source

pub fn is_complex(&self) -> bool

A complex selector targets multiple targets. Note the internal ranged selector is not counted as part of this category.

source

pub fn to_json(&self, store: &AnnotationStore) -> Result<String, StamError>

Writes a Selector to a STAM JSON string, with appropriate formatting

source

pub fn to_json_compact( &self, store: &AnnotationStore ) -> Result<String, StamError>

Writes a Selector to a STAM JSON string, without indentation

source

pub fn subselectors(&self) -> Option<&Vec<Selector>>

Returns all subselectors. Use [’iter()`] instead if you want an iterator with more functionality.

source§

impl Selector

source

pub fn iter<'a>( &'a self, store: &'a AnnotationStore, recurse_annotation: bool, track_ancestors: bool ) -> SelectorIter<'a>

Returns an iterator that yields all Selectors under a particular selector, including the selcetor in question as well. The parameter recurse_annotation determines whether an AnnotationSelector will be resolved recursively or not (finding all it points at)

Trait Implementations§

source§

impl Clone for Selector

source§

fn clone(&self) -> Selector

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 Debug for Selector

source§

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

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

impl From<&Selector> for SelectorKind

source§

fn from(selector: &Selector) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Selector> for Selector

source§

fn eq(&self, other: &Selector) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Selector

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

§

fn vzip(self) -> V