pub struct RichText { /* private fields */ }Expand description
Rich text with facet annotations.
Text is stored as a UTF-8 string. Facet indices are UTF-8 byte offsets, which is Rust’s native string indexing — no conversion needed.
Implementations§
Source§impl RichText
impl RichText
Sourcepub fn new(text: impl Into<String>, facets: Option<Vec<Facet>>) -> Self
pub fn new(text: impl Into<String>, facets: Option<Vec<Facet>>) -> Self
Create a new RichText from text, optionally with pre-detected facets.
Sourcepub fn grapheme_length(&self) -> usize
pub fn grapheme_length(&self) -> usize
Grapheme cluster count (user-perceived characters).
Sourcepub fn detect_facets(&mut self)
pub fn detect_facets(&mut self)
Detect facets (mentions, links, tags) in the text.
This does NOT resolve @mentions to DIDs — use detect_facets_with_resolver
for that. Mentions will have did set to the handle text.
Sourcepub fn insert(&mut self, index: usize, insert_text: &str)
pub fn insert(&mut self, index: usize, insert_text: &str)
Insert text at a UTF-8 byte offset, adjusting facets.
Sourcepub fn delete(&mut self, start: usize, end: usize)
pub fn delete(&mut self, start: usize, end: usize)
Delete a byte range [start, end), adjusting facets.
Sourcepub fn segments(&self) -> Vec<RichTextSegment>
pub fn segments(&self) -> Vec<RichTextSegment>
Iterate over segments of the rich text.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RichText
impl RefUnwindSafe for RichText
impl Send for RichText
impl Sync for RichText
impl Unpin for RichText
impl UnsafeUnpin for RichText
impl UnwindSafe for RichText
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more