pub struct Builder { /* private fields */ }Expand description
A builder to construct AnnotatedString.
Implementations§
Source§impl Builder
impl Builder
pub fn new() -> Builder
Sourcepub fn push_style(self, style: SpanStyle) -> Builder
pub fn push_style(self, style: SpanStyle) -> Builder
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) -> Builder
pub fn push_paragraph_style(self, style: ParagraphStyle) -> Builder
Applies the given ParagraphStyle to any appended text until a corresponding pop is called.
Sourcepub fn push_string_annotation(self, tag: &str, annotation: &str) -> Builder
pub fn push_string_annotation(self, tag: &str, annotation: &str) -> Builder
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) -> Builder
pub fn push_link(self, link: LinkAnnotation) -> Builder
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(Builder) -> Builder,
) -> Builder
pub fn with_link( self, link: LinkAnnotation, block: impl FnOnce(Builder) -> Builder, ) -> Builder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.