pub struct Builder { /* private fields */ }Expand description
A builder to construct AnnotatedString.
Implementations§
Source§impl Builder
impl Builder
pub fn new() -> Self
pub fn append_annotated(self, annotated: &AnnotatedString) -> Self
pub fn append_annotated_subsequence( self, annotated: &AnnotatedString, range: Range<usize>, ) -> Self
Sourcepub fn push_style(self, style: SpanStyle) -> Self
pub fn push_style(self, style: SpanStyle) -> Self
Applies the given SpanStyle to any appended text until a corresponding pop is called.
Returns the index of the pushed style, which can be passed to pop_to or used as an ID.
Sourcepub fn push_paragraph_style(self, style: ParagraphStyle) -> Self
pub fn push_paragraph_style(self, style: ParagraphStyle) -> Self
Applies the given ParagraphStyle to any appended text until a corresponding pop is called.
Sourcepub fn push_string_annotation(self, tag: &str, annotation: &str) -> Self
pub fn push_string_annotation(self, tag: &str, annotation: &str) -> Self
Pushes a string annotation covering subsequent appended text until the matching pop.
JC parity: Builder.pushStringAnnotation(tag, annotation)
Sourcepub fn push_link(self, link: LinkAnnotation) -> Self
pub fn push_link(self, link: LinkAnnotation) -> Self
Pushes a LinkAnnotation covering subsequent appended text.
Call [pop] when done, or use [with_link] for the block form.
JC parity: Builder.pushLink(link)
Sourcepub fn with_link(
self,
link: LinkAnnotation,
block: impl FnOnce(Self) -> Self,
) -> Self
pub fn with_link( self, link: LinkAnnotation, block: impl FnOnce(Self) -> Self, ) -> Self
Sourcepub fn to_annotated_string(self) -> AnnotatedString
pub fn to_annotated_string(self) -> AnnotatedString
Completes the builder, resolving open styles to the end of the text.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl !Send for Builder
impl !Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl !UnwindSafe for Builder
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