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
Internal selector pointing directly to a TextSelection, exposed as TextSelector to the outside world
InternalAnnotationTextSelector
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
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
impl Selector
sourcepub fn kind(&self) -> SelectorKind
pub fn kind(&self) -> SelectorKind
Returns a SelectorKind
sourcepub fn is_complex(&self) -> bool
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.
sourcepub fn to_json(&self, store: &AnnotationStore) -> Result<String, StamError>
pub fn to_json(&self, store: &AnnotationStore) -> Result<String, StamError>
Writes a Selector to a STAM JSON string, with appropriate formatting
sourcepub fn to_json_compact(
&self,
store: &AnnotationStore
) -> Result<String, StamError>
pub fn to_json_compact( &self, store: &AnnotationStore ) -> Result<String, StamError>
Writes a Selector to a STAM JSON string, without indentation
sourcepub fn subselectors(&self) -> Option<&Vec<Selector>>
pub fn subselectors(&self) -> Option<&Vec<Selector>>
Returns all subselectors. Use [’iter()`] instead if you want an iterator with more functionality.
source§impl Selector
impl Selector
sourcepub fn iter<'a>(
&'a self,
store: &'a AnnotationStore,
recurse_annotation: bool,
track_ancestors: bool
) -> SelectorIter<'a> ⓘ
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)