Struct hime_redist::text::Text

source ·
pub struct Text<'a> { /* private fields */ }
Expand description

Represents the input of parser with some metadata for line endings All line numbers and column numbers are 1-based. Indices in the content are 0-based.

Implementations§

source§

impl<'a> Text<'a>

source

pub fn into_static(self) -> Text<'static>

Transforms into an owned static version of the data

source

pub fn from_str(content: &'a str) -> Text<'a>

Initializes this text

source

pub fn from_string(content: String) -> Text<'static>

Initializes this text

source

pub fn from_utf8_stream(input: &mut dyn Read) -> Result<Text<'static>, Error>

Initializes this text from a UTF-8 stream

Errors

Return an error when reading the input fails.

source

pub fn get_line_count(&self) -> usize

Gets the number of lines

source

pub fn is_empty(&self) -> bool

Gets whether the text is empty

source

pub fn len(&self) -> usize

Gets the size in number of characters

source

pub fn is_end(&self, index: usize) -> bool

Gets whether the specified index is after the end of the text represented by this object

source

pub fn at(&self, index: usize) -> char

Gets the character at the specified index

Panics

Panic when index is at or beyond the end of the content

source

pub fn get_value(&self, index: usize, length: usize) -> &str

Gets the substring beginning at the given index with the given length

source

pub fn get_value_for(&self, span: TextSpan) -> &str

Get the substring corresponding to the specified span

source

pub fn get_value_at(&self, position: TextPosition, length: usize) -> &str

Get the substring corresponding to the text at the specified position and the given length

source

pub fn get_index_at(&self, position: TextPosition) -> usize

Gets the index within the content of the specified position

source

pub fn get_line_index(&self, line: usize) -> usize

Gets the starting index of the i-th line

source

pub fn get_line_length(&self, line: usize) -> usize

Gets the length of the i-th line

source

pub fn get_line_content(&self, line: usize) -> &str

Gets the string content of the i-th line

source

pub fn get_position_at(&self, index: usize) -> TextPosition

Gets the position at the given index

source

pub fn get_position_for( &self, position: TextPosition, length: usize ) -> TextPosition

Gets the position for a starting position and a length

source

pub fn get_context_at(&self, position: TextPosition) -> TextContext<'_>

Gets the context description for the current text at the specified position

source

pub fn get_context_for( &self, position: TextPosition, length: usize ) -> TextContext<'_>

Gets the context description for the current text at the specified position

source

pub fn get_context_of(&self, span: TextSpan) -> TextContext<'_>

Gets the context description for the current text at the specified span

source

pub fn iter_utf16_from(&self, from: usize) -> Utf16Iter<'_>

Gets an iterator over the UTF-16 codepoints starting at a location

Trait Implementations§

source§

impl<'a> Clone for Text<'a>

source§

fn clone(&self) -> Text<'a>

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<'a> Debug for Text<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Text<'a>

§

impl<'a> Send for Text<'a>

§

impl<'a> Sync for Text<'a>

§

impl<'a> Unpin for Text<'a>

§

impl<'a> UnwindSafe for Text<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere 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 Twhere 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 Twhere 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.