Trait stam::Text

source ·
pub trait Text<'store, 'slf>
where 'store: 'slf,
{ // Required methods fn text(&'slf self) -> &'store str; fn textlen(&'slf self) -> usize; fn text_by_offset( &'slf self, offset: &Offset ) -> Result<&'store str, StamError>; fn utf8byte(&'slf self, abscursor: usize) -> Result<usize, StamError>; fn utf8byte_to_charpos( &'slf self, bytecursor: usize ) -> Result<usize, StamError>; fn absolute_cursor(&'slf self, cursor: usize) -> usize; // Provided methods fn subslice_utf8_offset(&'slf self, subslice: &str) -> Option<usize> { ... } fn is_empty(&'slf self) -> bool { ... } fn absolute_offset(&'slf self, offset: &Offset) -> Result<Offset, StamError> { ... } fn beginaligned_cursor( &'slf self, cursor: &Cursor ) -> Result<usize, StamError> { ... } }
Expand description

This trait provides methods that operate on structures that hold or represent text content. They are fairly low-level methods but are exposed in the public API. The FindText trait subsequently builds upon this one with high-level search methods.

Required Methods§

source

fn text(&'slf self) -> &'store str

Returns a reference to the text

source

fn textlen(&'slf self) -> usize

Returns the length of the text in unicode points For bytes, use Self::text().len() instead.

source

fn text_by_offset(&'slf self, offset: &Offset) -> Result<&'store str, StamError>

Returns a string reference to a slice of text as specified by the offset

source

fn utf8byte(&'slf self, abscursor: usize) -> Result<usize, StamError>

Converts a unicode character position to a UTF-8 byte position

source

fn utf8byte_to_charpos( &'slf self, bytecursor: usize ) -> Result<usize, StamError>

Converts a UTF-8 byte position into a unicode position

source

fn absolute_cursor(&'slf self, cursor: usize) -> usize

Resolves a begin-aligned cursor to an absolute cursor (i.e. relative to the TextResource).

Provided Methods§

source

fn subslice_utf8_offset(&'slf self, subslice: &str) -> Option<usize>

Finds the utf-8 byte position where the specified text subslice begins The returned offset is relative to the TextSelection

source

fn is_empty(&'slf self) -> bool

source

fn absolute_offset(&'slf self, offset: &Offset) -> Result<Offset, StamError>

Resolves a relative offset (relative to another TextSelection) to an absolute one (in terms of to the underlying TextResource)

source

fn beginaligned_cursor(&'slf self, cursor: &Cursor) -> Result<usize, StamError>

Resolves a cursor to a begin aligned cursor, resolving all relative end-aligned positions

Implementors§

source§

impl<'store> Text<'store, 'store> for TextResource

source§

impl<'store, 'slf> Text<'store, 'slf> for ResultTextSelection<'store>
where 'store: 'slf,

source§

impl<'store, 'slf> Text<'store, 'slf> for ResultItem<'store, TextResource>
where 'store: 'slf,

this implementation mostly defers directly to the wrapped item, documentation is found on the trait and not repeated here

source§

impl<'store, 'slf> Text<'store, 'slf> for ResultItem<'store, TextSelection>
where 'store: 'slf,