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, end offset and optionally a handle.
if the textselection is already known in the model.
This is similar to Offset, but that one uses cursors which may
be relative. TextSelection specifies 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, such as in the higher-level wrapper ResultTextSelection.
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,
offsetmode: OffsetMode
) -> Option<Offset>
pub fn relative_offset( &self, container: &TextSelection, offsetmode: OffsetMode ) -> 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.
sourcepub fn textselection_by_offset(
&self,
offset: &Offset
) -> Result<TextSelection, StamError>
pub fn textselection_by_offset( &self, offset: &Offset ) -> Result<TextSelection, StamError>
Low-level method to get a textselection inside the current one Note: this is a low level method and will always return an unbound textselection!
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 DataSize for TextSelection
impl DataSize for TextSelection
source§const IS_DYNAMIC: bool = false
const IS_DYNAMIC: bool = false
true, the type has a heap size that can vary at runtime, depending on the actual value.source§const STATIC_HEAP_SIZE: usize = 0usize
const STATIC_HEAP_SIZE: usize = 0usize
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
fn estimate_heap_size(&self) -> usize
source§impl Debug for TextSelection
impl Debug for TextSelection
source§impl<'bytes, Ctx> Decode<'bytes, Ctx> for TextSelection
impl<'bytes, Ctx> Decode<'bytes, Ctx> for TextSelection
source§impl<Ctx> Encode<Ctx> for TextSelection
impl<Ctx> Encode<Ctx> 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 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 for TextSelection
impl PartialEq 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 for TextSelection
impl PartialOrd 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<'a> Request<TextSelection> for TextSelectionHandle
impl<'a> Request<TextSelection> for TextSelectionHandle
source§fn to_handle<'store, S>(&self, _store: &'store S) -> Option<TextSelectionHandle>where
S: StoreFor<TextSelection>,
fn to_handle<'store, S>(&self, _store: &'store S) -> Option<TextSelectionHandle>where
S: StoreFor<TextSelection>,
source§fn requested_id(&self) -> Option<&str>
fn requested_id(&self) -> Option<&str>
source§fn requested_id_owned(self) -> Option<String>
fn requested_id_owned(self) -> Option<String>
source§fn requested_handle(&self) -> Option<T::HandleType>
fn requested_handle(&self) -> Option<T::HandleType>
source§impl Storable for TextSelection
impl Storable for TextSelection
type HandleType = TextSelectionHandle
type StoreHandleType = TextResourceHandle
type FullHandleType = (TextResourceHandle, TextSelectionHandle)
type StoreType = TextResource
source§fn handle(&self) -> Option<TextSelectionHandle>
fn handle(&self) -> Option<TextSelectionHandle>
StoreFor<T>, this may return None only in the initial
stage when it is still unbounded to a store, so this is almost always safe to unwrap when used in the public API.source§fn with_handle(self, handle: TextSelectionHandle) -> Self
fn with_handle(self, handle: TextSelectionHandle) -> Self
source§fn carries_id() -> bool
fn carries_id() -> bool
fn fullhandle( storehandle: Self::StoreHandleType, handle: Self::HandleType ) -> Self::FullHandleType
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 temp_id(&self) -> Result<String, StamError>
fn temp_id(&self) -> Result<String, StamError>
source§fn as_resultitem<'store>(
&'store self,
store: &'store Self::StoreType,
rootstore: &'store AnnotationStore
) -> ResultItem<'store, Self>where
Self: Sized,
fn as_resultitem<'store>(
&'store self,
store: &'store Self::StoreType,
rootstore: &'store AnnotationStore
) -> ResultItem<'store, Self>where
Self: Sized,
T as a ResultItem<T>, i.e. a wrapped reference that includes a reference to
both this item as well as the store that owns it. All high-level API functions are implemented
on such Result types. You should not need to invoke this yourself.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
fn store_typeinfo() -> &'static str
source§fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>
source§fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
fn add(self, item: T) -> Result<Self, StamError>where
Self: Sized,
source§unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>
source§fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
fn get(&self, item: impl Request<T>) -> Result<&T, StamError>
AnnotationStore::annotation() instead.source§fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>
source§fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>
source§fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>
source§fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
fn iter(&self) -> StoreIter<'_, T>where
T: Storable<StoreType = Self>,
annotations(), resources() instead. source§fn iter_mut(&mut self) -> StoreIterMut<'_, T>
fn iter_mut(&mut self) -> StoreIterMut<'_, T>
source§fn next_handle(&self) -> T::HandleType
fn next_handle(&self) -> T::HandleType
source§fn last_handle(&self) -> T::HandleType
fn last_handle(&self) -> T::HandleType
source§impl TestTextSelection for TextSelection
impl TestTextSelection for TextSelection
source§fn test(
&self,
operator: &TextSelectionOperator,
reftextsel: &TextSelection
) -> bool
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.
source§fn test_set(
&self,
operator: &TextSelectionOperator,
refset: &TextSelectionSet
) -> bool
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.