StyledStr

Struct StyledStr 

Source
pub struct StyledStr { /* private fields */ }
Expand description

A string with associated text attributes for rich text formatting.

Implementations§

Source§

impl StyledStr

Source

pub const fn empty() -> Self

Creates a new empty StyledStr.

Source

pub fn from_markdown(markdown: &str) -> Self

Creates a styled string from a subset of Markdown.

Supported features include headings, bold, and italic text. Other Markdown constructs are preserved as plain text.

Source

pub fn plain(text: impl Into<Str>) -> Self

Creates a plain attributed string with a single unstyled chunk.

Source

pub fn push(&mut self, text: impl Into<Str>, style: Style)

Adds a new text chunk with the specified style.

Source

pub fn push_str(&mut self, text: impl Into<Str>)

Appends text to the last chunk, or creates a new chunk if empty.

Source

pub fn len(&self) -> usize

Returns the total length of the attributed string.

Source

pub const fn is_empty(&self) -> bool

Checks if the attributed string is empty.

Source

pub fn to_plain(&self) -> Str

Converts the attributed string into its plain representation.

Source

pub fn into_chunks(self) -> Vec<(Str, Style)>

Consumes the attributed string and returns its constituent chunks.

Source

pub fn set_style(self, style: &Style) -> Self

Sets the style for all text in this styled text.

Source

pub fn size(self, size: f32) -> Self

Sets the font size for all chunks.

Source

pub fn font(self, font: &Font) -> Self

Sets the font for all chunks.

Source

pub fn foreground(self, color: impl Into<Color>) -> Self

Sets the foreground color for all chunks.

Source

pub fn background_color(self, color: impl Into<Color>) -> Self

Sets the background color for all chunks.

Source

pub fn weight(self, weight: FontWeight) -> Self

Sets the font weight for all chunks.

Source

pub fn bold(self) -> Self

Sets the font to bold for all chunks.

Source

pub fn italic(self, italic: bool) -> Self

Sets the italic style for all chunks.

Source

pub fn underline(self, underline: bool) -> Self

Sets the underline style for all chunks.

Source

pub fn strikethrough(self, strikethrough: bool) -> Self

Sets the strikethrough style for all chunks.

Trait Implementations§

Source§

impl Add<&'static str> for StyledStr

Source§

type Output = StyledStr

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'static str) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for StyledStr

Source§

type Output = StyledStr

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for StyledStr

Source§

fn clone(&self) -> StyledStr

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StyledStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StyledStr

Source§

fn default() -> StyledStr

Returns the “default value” for a type. Read more
Source§

impl Display for StyledStr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Extend<(Str, Style)> for StyledStr

Source§

fn extend<T: IntoIterator<Item = (Str, Style)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&'static str> for StyledStr

Source§

fn from(value: &'static str) -> Self

Converts to this type from the input type.
Source§

impl From<Str> for StyledStr

Source§

fn from(value: Str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for StyledStr

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl Signal for StyledStr

Source§

type Output = StyledStr

The type of value produced by this computation.
Source§

type Guard = ()

The guard type returned by the watch method that manages watcher lifecycle.
Source§

fn get(&self) -> Self::Output

Execute the computation and return the current value.
Source§

fn watch(&self, _watcher: impl Fn(Context<Self::Output>) + 'static)

Register a watcher to be notified when the computed value changes. Read more
Source§

impl View for StyledStr

Source§

fn body(self, _env: &Environment) -> impl View

Build this view and return the content. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S> AnimationExt for S
where S: SignalExt,

Source§

fn animated(self) -> WithMetadata<Self, Animation>
where Self: Sized,

Apply default animation to this reactive value Read more
Source§

fn with_animation(self, animation: Animation) -> WithMetadata<Self, Animation>
where Self: Sized,

Apply a specific animation to this reactive value Read more
§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IdentifiableExt for T

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<C, Output> IntoSignal<Output> for C
where C: Signal, <C as Signal>::Output: 'static + Clone, Output: From<<C as Signal>::Output> + 'static,

Source§

fn into_signal(self) -> <C as IntoSignal<Output>>::Signal

Convert this computation into one that produces the desired output type.

Source§

type Signal = Map<C, fn(<C as Signal>::Output) -> Output, Output>

The specific computation type that will be produced.
Source§

impl<V> IntoView for V
where V: View,

Source§

type Output = V

The resulting View type after conversion.
Source§

fn into_view(self, _env: &Environment) -> <V as IntoView>::Output

Converts the implementing type into a View. Read more
Source§

impl<C> SignalExt for C
where C: Signal,

Source§

fn map<F, Output>(self, f: F) -> Map<Self, F, Output>
where F: 'static + Clone + Fn(Self::Output) -> Output, Output: 'static, Self: 'static,

Transforms the output of this signal using the provided function.
Source§

fn zip<B>(self, b: B) -> Zip<Self, B>
where B: Signal, Self::Output: Clone, <B as Signal>::Output: Clone,

Combines this signal with another signal into a tuple.
Source§

fn cached(self) -> Cached<Self>
where Self::Output: Clone,

Wraps this signal with caching to avoid redundant computations.
Source§

fn computed(self) -> Computed<Self::Output>
where Self: 'static,

Converts this signal into a type-erased Computed container.
Source§

fn with<T>(self, metadata: T) -> WithMetadata<Self, T>

Attaches metadata to this signal’s watcher notifications.
Source§

fn debounce(self, duration: Duration) -> Debounce<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a debounced version of this signal. Read more
Source§

fn throttle(self, duration: Duration) -> Throttle<Self, DefaultExecutor>
where Self::Output: Clone,

Creates a throttled version of this signal. Read more
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.