Skip to main content

AddressableInlinePiece

Struct AddressableInlinePiece 

Source
pub struct AddressableInlinePiece {
    pub start: u32,
    pub end: u32,
    pub content: InlineContent,
    pub format: CharacterFormat,
}
Expand description

InlinePiece, but positioned in the document’s own addressable character space rather than as byte offsets local to the block’s plain_text.

InlinePiece::Text { start, end, .. } is a byte range good for slicing plain_text and nothing else: it carries no notion of where in the document that range sits. Every offset the rest of this crate deals out — TextDocument::to_addressable_text(), find_all match positions, a block’s own document_position — lives in one character space, and a caller that reconstructs a document position by summing InlinePiece text lengths drifts the moment a block holds a multi-byte character before the point in question, or an inline image/footnote reference at all — their U+FFFC sentinel is three bytes but one char (see sentinel_len on merge_runs_and_anchors). That is the same “offset from one space, string from another” bug class the public API’s TextDocument::to_addressable_text() exists to close for whole-document offsets (see its doc comment), one level down, inside a single block.

Built by addressable_inline_pieces (pure — block-local character space, base_char_offset left at 0) or crate::format_runs_query::addressable_inline_pieces_for_block (store-aware — adds the block’s own document_position so start/end land in the document’s space). Every downstream consumer that needs a piece boundary in that space — a comment’s stored quote, a DOCX/ODT comment marker split at an arbitrary character — reads start/end straight off this type instead of re-deriving them by hand.

Fields§

§start: u32

[start, end) in the addressable character space. end - start is always 1 for InlineContent::Image and InlineContent::FootnoteRef — the sentinel counts as exactly one character, matching how the document itself counts it — and equals the piece’s own text’s chars().count() for InlineContent::Text.

§end: u32§content: InlineContent§format: CharacterFormat

Trait Implementations§

Source§

impl Clone for AddressableInlinePiece

Source§

fn clone(&self) -> AddressableInlinePiece

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 Debug for AddressableInlinePiece

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AddressableInlinePiece

Source§

fn eq(&self, other: &AddressableInlinePiece) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AddressableInlinePiece

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> 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.