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

source

pub fn begin(&self) -> usize

Return the begin position (unicode points)

source

pub fn end(&self) -> usize

Return the end position (non-inclusive) in unicode points

source

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.

source

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.

source

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.

source

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

source§

fn clone(&self) -> TextSelection

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 TextSelection

source§

const IS_DYNAMIC: bool = false

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

const STATIC_HEAP_SIZE: usize = 0usize

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 TextSelection

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 TextSelection

source§

fn decode( __d777: &mut Decoder<'bytes>, __ctx777: &mut Ctx ) -> Result<TextSelection, 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 TextSelection

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 Extend<TextSelection> for TextSelectionSet

source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = TextSelection>,

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl From<&TextSelection> for Offset

source§

fn from(textselection: &TextSelection) -> Offset

Converts to this type from the input type.
source§

impl From<TextSelection> for Offset

source§

fn from(textselection: TextSelection) -> Offset

Converts to this type from the input type.
source§

impl Hash for TextSelection

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for TextSelection

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for TextSelection

source§

fn eq(&self, other: &TextSelection) -> 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 PartialOrd for TextSelection

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a> Request<TextSelection> for TextSelectionHandle

source§

fn to_handle<'store, S>(&self, _store: &'store S) -> Option<TextSelectionHandle>

Returns the handle for this item, looking it up in the store
source§

fn requested_id(&self) -> Option<&str>

If this type encapsulates an Id, this returns it (borrowed)
source§

fn requested_id_owned(self) -> Option<String>

If this type encapsulates an Id, this returns it (oened)
source§

fn requested_handle(&self) -> Option<T::HandleType>

If this type encapsulates a handle, this returns it
source§

fn any(&self) -> bool

Represents a request for any value in certain contexts
source§

impl Storable for TextSelection

§

type HandleType = TextSelectionHandle

§

type StoreHandleType = TextResourceHandle

§

type FullHandleType = (TextResourceHandle, TextSelectionHandle)

§

type StoreType = TextResource

source§

fn id(&self) -> Option<&str>

Get the public identifier
source§

fn handle(&self) -> Option<TextSelectionHandle>

Retrieve the internal (numeric) id. For any type T in 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

Set the internal ID for an item. May only be called once just after instantiation. This is a low-level API method that can not be used publicly due to ownership restrictions.
source§

fn carries_id() -> bool

Does this type support an ID?
source§

fn fullhandle( storehandle: Self::StoreHandleType, handle: Self::HandleType ) -> Self::FullHandleType

source§

fn handle_or_err(&self) -> Result<Self::HandleType, StamError>

Like Self::handle() but returns a StamError::Unbound error if there is no internal id.
source§

fn temp_id(&self) -> Result<String, StamError>

Generate a temporary public ID based on the internal handle.
source§

fn as_resultitem<'store>( &'store self, store: &'store Self::StoreType, rootstore: &'store AnnotationStore ) -> ResultItem<'store, Self>
where Self: Sized,

Returns the item of type 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>>) -> Self
where Self: Sized,

Generate a random ID in a given idmap (adds it to the map and assigns it to the item) This is a low-level API method that can not be used publicly due to ownership restrictions.
source§

fn with_id(self, id: impl Into<String>) -> Self
where Self: Sized,

Builder pattern to set the public ID
source§

impl StoreFor<TextSelection> for TextResource

source§

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>

Get a mutable reference to the entire store for the associated type

source§

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

Get a mutable reference to the id map for the associated type, mapping global ids to internal ids

source§

fn store_typeinfo() -> &'static str

source§

fn insert(&mut self, item: T) -> Result<T::HandleType, StamError>

Adds an item to the store. Returns a handle to it upon success.
source§

fn add(self, item: T) -> Result<Self, StamError>
where Self: Sized,

Inserts items into the store using a builder pattern
source§

fn has(&self, item: impl Request<T>) -> bool

Returns true if the store has the item
source§

unsafe fn get_unchecked(&self, handle: T::HandleType) -> Option<&T>

Get a reference to an item from the store, by handle, without checking validity. Read more
source§

fn get(&self, item: impl Request<T>) -> Result<&T, StamError>

Get a reference to an item from the store This is a low-level API method, you usually want to use dedicated high-level methods like AnnotationStore::annotation() instead.
source§

fn get_mut(&mut self, item: impl Request<T>) -> Result<&mut T, StamError>

Get a mutable reference to an item from the store by internal ID This is a low-level API method
source§

fn remove(&mut self, handle: T::HandleType) -> Result<(), StamError>

Removes an item by handle, returns an error if the item has dependencies and can’t be removed
source§

fn resolve_id(&self, id: &str) -> Result<T::HandleType, StamError>

Resolves an ID to a handle. Also works for temporary IDs if enabled. This is a low-level API method. You usually don’t want to call this directly.
source§

fn iter(&self) -> StoreIter<'_, T>
where T: Storable<StoreType = Self>,

Iterate over all items in the store This is a low-level API method, use dedicated high-level iterators like annotations(), resources() instead.
source§

fn iter_mut(&mut self) -> StoreIterMut<'_, T>

Iterate over the store, mutably This is a low-level API method.
source§

fn next_handle(&self) -> T::HandleType

Return the internal id that will be assigned for the next item to the store This is a low-level API method.
source§

fn last_handle(&self) -> T::HandleType

Return the internal id that was assigned to last inserted item This is a low-level API method.
source§

impl TestTextSelection for TextSelection

source§

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

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.

source§

impl TypeInfo for TextSelection

source§

fn typeinfo() -> Type

Return the type (introspection).
source§

fn temp_id_prefix() -> &'static str

Return the prefix for temporary identifiers of this type
source§

impl Copy for TextSelection

source§

impl Eq for TextSelection

source§

impl StructuralEq for TextSelection

source§

impl StructuralPartialEq for TextSelection

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<'store, I> SortTextualOrder<TextSelection> for I
where I: Iterator<Item = TextSelection>,

source§

fn textual_order(&mut self) -> Vec<TextSelection>

Sorts items in the iterator in textual order, meaningthat items are returned in the same order as they appear in the original text. items that do not relate to text at all will be put at the end with arbitrary sorting This method allocates and returns a buffer to do the sorting. Read more
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.
§

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

§

fn vzip(self) -> V