Struct stam::TextSelection
source · pub struct TextSelection { /* private fields */ }Expand description
Corresponds to a slice of the text. This only contains minimal
information; i.e. the begin offset and end offset.
This is similar to Offset, but that one uses cursors which may
be relative. TextSelection specified an offset in more absolute terms.
The actual reference to the crate::TextResource is not stored in this structure but should
accompany it explicitly when needed
On the lowest-level, this struct is obtain by a call to crate::annotationstore::AnnotationStore::textselection(), which
resolves a crate::Selector::TextSelector to a TextSelection. Such calls are often abstracted away by higher level methods such as [crate::annotationstore::AnnotationStore::textselections_by_annotation()].
Implementations§
source§impl TextSelection
impl TextSelection
sourcepub fn relative_begin(&self, container: &TextSelection) -> Option<usize>
pub fn relative_begin(&self, container: &TextSelection) -> Option<usize>
Returns the begin cursor of this text selection in another. Returns None if they are not embedded. Note: this does NOT check whether the textselections pertain to the same resource, that is up to the caller.
sourcepub fn relative_end(&self, container: &TextSelection) -> Option<usize>
pub fn relative_end(&self, container: &TextSelection) -> Option<usize>
Returns the end cursor (begin-aligned) of this text selection in another. Returns None if they are not embedded. Note: this does NOT check whether the textselections pertain to the same resource, that is up to the caller.
sourcepub fn relative_offset(&self, container: &TextSelection) -> Option<Offset>
pub fn relative_offset(&self, container: &TextSelection) -> Option<Offset>
Returns the offset of this text selection in another. Returns None if they are not embedded. Note: this does NOT check whether the textselections pertain to the same resource, that is up to the caller.
source§impl TextSelection
impl TextSelection
sourcepub fn test(
&self,
operator: &TextSelectionOperator,
reftextsel: &TextSelection
) -> bool
pub fn test( &self, operator: &TextSelectionOperator, reftextsel: &TextSelection ) -> bool
This method is called to test whether a specific spatial relation (as expressed by the
passed operator) holds between a TextSelection and another.
A boolean is returned with the test result.
sourcepub fn test_set(
&self,
operator: &TextSelectionOperator,
refset: &TextSelectionSet
) -> bool
pub fn test_set( &self, operator: &TextSelectionOperator, refset: &TextSelectionSet ) -> bool
This method is called to test whether a specific spatial relation (as expressed by the
passed operator) holds between a TextSelection and another (or multiple)
(TextSelectionSet). The operator contains the other part of the equation that is tested
against. A boolean is returned with the test result.
Trait Implementations§
source§impl Clone for TextSelection
impl Clone for TextSelection
source§fn clone(&self) -> TextSelection
fn clone(&self) -> TextSelection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for TextSelection
impl Debug for TextSelection
source§impl Extend<TextSelection> for TextSelectionSet
impl Extend<TextSelection> for TextSelectionSet
source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = TextSelection>,
fn extend<T>(&mut self, iter: T)where T: IntoIterator<Item = TextSelection>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)source§impl From<&TextSelection> for Offset
impl From<&TextSelection> for Offset
source§fn from(textselection: &TextSelection) -> Offset
fn from(textselection: &TextSelection) -> Offset
source§impl Hash for TextSelection
impl Hash for TextSelection
source§impl Ord for TextSelection
impl Ord for TextSelection
source§impl PartialEq<TextSelection> for TextSelection
impl PartialEq<TextSelection> for TextSelection
source§fn eq(&self, other: &TextSelection) -> bool
fn eq(&self, other: &TextSelection) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd<TextSelection> for TextSelection
impl PartialOrd<TextSelection> for TextSelection
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl Storable for TextSelection
impl Storable for TextSelection
type HandleType = TextSelectionHandle
type StoreType = TextResource
source§fn handle(&self) -> Option<TextSelectionHandle>
fn handle(&self) -> Option<TextSelectionHandle>
StoreFor<T>, this may be None only in the initial
stage when it is still unbounded to a store.source§fn set_handle(&mut self, handle: TextSelectionHandle)
fn set_handle(&mut self, handle: TextSelectionHandle)
source§fn carries_id() -> bool
fn carries_id() -> bool
source§fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
fn handle_or_err(&self) -> Result<Self::HandleType, StamError>
Self::handle() but returns a StamError::Unbound error if there is no internal id.source§fn id_or_err(&self) -> Result<&str, StamError>
fn id_or_err(&self) -> Result<&str, StamError>
Self::id() but returns a StamError::NoIdError error if there is no internal id.source§fn wrap_in<'store>(
&'store self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_in<'store>( &'store self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
StoreFor<T>::wrap()source§fn wrap_owned_in<'store>(
self,
store: &'store Self::StoreType
) -> Result<WrappedItem<'store, Self>, StamError>where
Self: Sized,
fn wrap_owned_in<'store>( self, store: &'store Self::StoreType ) -> Result<WrappedItem<'store, Self>, StamError>where Self: Sized,
StoreFor<T>::wrap_owned()source§fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere
Self: Sized,
fn generate_id(self, idmap: Option<&mut IdMap<Self::HandleType>>) -> Selfwhere Self: Sized,
source§impl StoreFor<TextSelection> for TextResource
impl StoreFor<TextSelection> for TextResource
source§fn store(&self) -> &Store<TextSelection>
fn store(&self) -> &Store<TextSelection>
Get a reference to the entire store for the associated type
source§fn store_mut(&mut self) -> &mut Store<TextSelection>
fn store_mut(&mut self) -> &mut Store<TextSelection>
Get a mutable reference to the entire store for the associated type
source§fn idmap(&self) -> Option<&IdMap<TextSelectionHandle>>
fn idmap(&self) -> Option<&IdMap<TextSelectionHandle>>
Get a reference to the id map for the associated type, mapping global ids to internal ids
source§fn idmap_mut(&mut self) -> Option<&mut IdMap<TextSelectionHandle>>
fn idmap_mut(&mut self) -> Option<&mut IdMap<TextSelectionHandle>>
Get a mutable reference to the id map for the associated type, mapping global ids to internal ids