pub struct Builder { /* private fields */ }Expand description
A builder to construct AnnotatedString.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn append_annotated(self, annotated: &AnnotatedString) -> Self
pub fn append_annotated(self, annotated: &AnnotatedString) -> Self
Appends the text of annotated together with its styles and annotations.
Sourcepub fn append_annotated_subsequence(
self,
annotated: &AnnotatedString,
range: Range<usize>,
) -> Self
pub fn append_annotated_subsequence( self, annotated: &AnnotatedString, range: Range<usize>, ) -> Self
Appends the bytes of annotated in range with the styles and annotations that overlap
them. The range is clamped to the text and both ends must lie on character boundaries.
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.