Enum stam::Selector

source ·
pub enum Selector {
    TextSelector(TextResourceHandle, TextSelectionHandle, OffsetMode),
    AnnotationSelector(AnnotationHandle, Option<(TextResourceHandle, TextSelectionHandle, OffsetMode)>),
    ResourceSelector(TextResourceHandle),
    DataSetSelector(AnnotationDataSetHandle),
    MultiSelector(Vec<Selector>),
    CompositeSelector(Vec<Selector>),
    DirectionalSelector(Vec<Selector>),
    DataKeySelector(AnnotationDataSetHandle, DataKeyHandle),
    AnnotationDataSelector(AnnotationDataSetHandle, AnnotationDataHandle),
    RangedTextSelector {
        resource: TextResourceHandle,
        begin: TextSelectionHandle,
        end: TextSelectionHandle,
    },
    RangedAnnotationSelector {
        begin: AnnotationHandle,
        end: AnnotationHandle,
        with_text: bool,
    },
}
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§

§

TextSelector(TextResourceHandle, TextSelectionHandle, OffsetMode)

Refers to the TextResource and a TextSelection within

§

AnnotationSelector(AnnotationHandle, Option<(TextResourceHandle, TextSelectionHandle, OffsetMode)>)

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

§

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

§

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 crate::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)

§

DataKeySelector(AnnotationDataSetHandle, DataKeyHandle)

Refers to a DataKey to annotate. Annotations using this selector are considered metadata of a key

§

AnnotationDataSelector(AnnotationDataSetHandle, AnnotationDataHandle)

Refers to a AnnotationData to annotate. Annotations using this selector can be considered metadata on specific data, it is fairly rare.

§

RangedTextSelector

Internal ranged selector, used as subselector for MultiSelector/CompositeSelector/DirectionalSelector

§

RangedAnnotationSelector

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

Fields

§with_text: bool

Implementations§

source§

impl Selector

source

pub fn kind(&self) -> SelectorKind

Returns a SelectorKind identifying the type of selector

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<&[Selector]>

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

source

pub fn textselection<'store>( &self, store: &'store AnnotationStore ) -> Option<&'store TextSelection>

Returns the textselection this selector points at, if any

source

pub fn textselection_handle(&self) -> Option<TextSelectionHandle>

Returns the textselection handle this selector points at, if any

source

pub fn resource_handle(&self) -> Option<TextResourceHandle>

Returns the handle of the resource this selector points at, if any

source

pub fn offset(&self, store: &AnnotationStore) -> Option<Offset>

Returns the associated offset if the selector carries one

source

pub fn offset_with_mode( &self, store: &AnnotationStore, override_mode: Option<OffsetMode> ) -> Option<Offset>

Returns the associated offset if the selector carries one You may set override_mode if you want to override the OffsetMode rather than take it from the selector

source§

impl Selector

source

pub fn iter<'a>( &'a self, store: &'a AnnotationStore, recurse_annotation: 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 DataSize for Selector

source§

const IS_DYNAMIC: bool = true

If true, the type has a heap size that can vary at runtime, depending on the actual value.
source§

const STATIC_HEAP_SIZE: usize = 8usize

The amount of space a value of the type always occupies. If IS_DYNAMIC is false, this is the total amount of heap memory occupied by the value. Otherwise this is a lower bound.
source§

fn estimate_heap_size(&self) -> usize

Estimates the size of heap memory taken up by this value. 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<'bytes, Ctx> Decode<'bytes, Ctx> for Selector

source§

fn decode( __d777: &mut Decoder<'bytes>, __ctx777: &mut Ctx ) -> Result<Selector, Error>

Decode a value using the given Decoder. Read more
source§

fn nil() -> Option<Self>

If possible, return a nil value of Self. Read more
source§

impl<Ctx> Encode<Ctx> for Selector

source§

fn encode<__W777>( &self, __e777: &mut Encoder<__W777>, __ctx777: &mut Ctx ) -> Result<(), Error<__W777::Error>>
where __W777: Write,

Encode a value of this type using the given Encoder. Read more
source§

fn is_nil(&self) -> bool

Is this value of Self a nil value? 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 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 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.

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

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<T> Same for T

§

type Output = T

Should always be Self
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.
source§

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

source§

fn vzip(self) -> V