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: CharacterFormatTrait Implementations§
Source§impl Clone for AddressableInlinePiece
impl Clone for AddressableInlinePiece
Source§fn clone(&self) -> AddressableInlinePiece
fn clone(&self) -> AddressableInlinePiece
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more