Skip to main content

LineIndex

Struct LineIndex 

Source
pub struct LineIndex<'text> { /* private fields */ }
Expand description

Reusable line index for strict Weavatrix v1 UTF-16 positions.

Implementations§

Source§

impl<'text> LineIndex<'text>

Source

pub fn new(text: &'text str) -> Self

Builds a reusable full line index.

This compatibility constructor retains its infallible signature. Code handling untrusted or very large text should use Self::try_new with explicit resource ceilings instead.

§Panics

Panics if the complete line-start table cannot be represented or allocated. Use Self::try_new to receive a bounded error instead.

Source

pub fn try_new( text: &'text str, limits: LineIndexLimits, ) -> Result<Self, EditError>

Builds a reusable full line index within explicit resource limits.

The source is borrowed rather than copied. The complete line-start table is counted before allocation, checked against both limits, and reserved fallibly so hostile newline-heavy input returns an error instead of relying on an allocator panic.

Source

pub fn byte_offset(&self, position: Position) -> Result<usize, EditError>

Resolves a 1-based line and 0-based UTF-16 code-unit position.

The line feed is excluded from the line length. For compatibility with weavatrix.edit-plan.v1, a preceding carriage return remains part of a CRLF line. Positions inside an astral Unicode scalar fail closed.

Source

pub fn byte_offset_with_encoding( &self, position: Position, encoding: PositionEncoding, ) -> Result<usize, EditError>

Resolves a strict position using UTF-8, UTF-16, or UTF-32 character units.

Source

pub fn position_at( &self, byte_offset: usize, encoding: PositionEncoding, ) -> Result<Position, EditError>

Maps a UTF-8 byte boundary back to a strict line/character position.

Source

pub fn line_count(&self) -> usize

Trait Implementations§

Source§

impl<'text> Clone for LineIndex<'text>

Source§

fn clone(&self) -> LineIndex<'text>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'text> Debug for LineIndex<'text>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'text> Freeze for LineIndex<'text>

§

impl<'text> RefUnwindSafe for LineIndex<'text>

§

impl<'text> Send for LineIndex<'text>

§

impl<'text> Sync for LineIndex<'text>

§

impl<'text> Unpin for LineIndex<'text>

§

impl<'text> UnsafeUnpin for LineIndex<'text>

§

impl<'text> UnwindSafe for LineIndex<'text>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

Source§

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

Source§

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.