Trait IntoText

Source
pub trait IntoText<'a>: Sized {
Show 32 methods // Required method fn into_cow_text(self) -> Cow<'a, Text>; // Provided methods fn into_text(self) -> Text { ... } fn color(self, color: impl Into<Color>) -> Text { ... } fn clear_color(self) -> Text { ... } fn font(self, font: Font) -> Text { ... } fn clear_font(self) -> Text { ... } fn bold(self) -> Text { ... } fn not_bold(self) -> Text { ... } fn clear_bold(self) -> Text { ... } fn italic(self) -> Text { ... } fn not_italic(self) -> Text { ... } fn clear_italic(self) -> Text { ... } fn underlined(self) -> Text { ... } fn not_underlined(self) -> Text { ... } fn clear_underlined(self) -> Text { ... } fn strikethrough(self) -> Text { ... } fn not_strikethrough(self) -> Text { ... } fn clear_strikethrough(self) -> Text { ... } fn obfuscated(self) -> Text { ... } fn not_obfuscated(self) -> Text { ... } fn clear_obfuscated(self) -> Text { ... } fn insertion(self, insertion: impl Into<Cow<'static, str>>) -> Text { ... } fn clear_insertion(self) -> Text { ... } fn on_click_open_url(self, url: impl Into<Cow<'static, str>>) -> Text { ... } fn on_click_run_command(self, command: impl Into<Cow<'static, str>>) -> Text { ... } fn on_click_suggest_command( self, command: impl Into<Cow<'static, str>>, ) -> Text { ... } fn on_click_change_page(self, page: impl Into<i32>) -> Text { ... } fn on_click_copy_to_clipboard( self, text: impl Into<Cow<'static, str>>, ) -> Text { ... } fn clear_click_event(self) -> Text { ... } fn on_hover_show_text(self, text: impl IntoText<'static>) -> Text { ... } fn clear_hover_event(self) -> Text { ... } fn add_child(self, text: impl IntoText<'static>) -> Text { ... }
}
Expand description

Trait for any data that can be converted to a Text object.

Also conveniently provides many useful methods for modifying a Text object.

§Usage

let mut my_text = "".into_text();
my_text = my_text.color(NamedColor::Red).bold();
my_text = my_text.add_child("CRABBBBB".obfuscated());

Required Methods§

Source

fn into_cow_text(self) -> Cow<'a, Text>

Converts to a Text object, either owned or borrowed.

Provided Methods§

Source

fn into_text(self) -> Text

Converts to an owned Text object.

Source

fn color(self, color: impl Into<Color>) -> Text

Sets the color of the text.

Source

fn clear_color(self) -> Text

Clears the color of the text. Color of parent Text object will be used.

Source

fn font(self, font: Font) -> Text

Sets the font of the text.

Source

fn clear_font(self) -> Text

Clears the font of the text. Font of parent Text object will be used.

Source

fn bold(self) -> Text

Makes the text bold.

Source

fn not_bold(self) -> Text

Makes the text not bold.

Source

fn clear_bold(self) -> Text

Clears the bold property of the text. Property of the parent Text object will be used.

Source

fn italic(self) -> Text

Makes the text italic.

Source

fn not_italic(self) -> Text

Makes the text not italic.

Source

fn clear_italic(self) -> Text

Clears the italic property of the text. Property of the parent Text object will be used.

Source

fn underlined(self) -> Text

Makes the text underlined.

Source

fn not_underlined(self) -> Text

Makes the text not underlined.

Source

fn clear_underlined(self) -> Text

Clears the underlined property of the text. Property of the parent Text object will be used.

Source

fn strikethrough(self) -> Text

Adds a strikethrough effect to the text.

Source

fn not_strikethrough(self) -> Text

Removes the strikethrough effect from the text.

Source

fn clear_strikethrough(self) -> Text

Clears the strikethrough property of the text. Property of the parent Text object will be used.

Source

fn obfuscated(self) -> Text

Makes the text obfuscated.

Source

fn not_obfuscated(self) -> Text

Makes the text not obfuscated.

Source

fn clear_obfuscated(self) -> Text

Clears the obfuscated property of the text. Property of the parent Text object will be used.

Source

fn insertion(self, insertion: impl Into<Cow<'static, str>>) -> Text

Adds an insertion property to the text. When shift-clicked, the given text will be inserted into chat box for the client.

Source

fn clear_insertion(self) -> Text

Clears the insertion property of the text. Property of the parent Text object will be used.

Source

fn on_click_open_url(self, url: impl Into<Cow<'static, str>>) -> Text

On click, opens the given URL. Has to be http or https protocol.

Source

fn on_click_run_command(self, command: impl Into<Cow<'static, str>>) -> Text

On click, sends a command. Doesn’t actually have to be a command, can be a simple chat message.

Source

fn on_click_suggest_command(self, command: impl Into<Cow<'static, str>>) -> Text

On click, copies the given text to the chat box.

Source

fn on_click_change_page(self, page: impl Into<i32>) -> Text

On click, turns the page of the opened book to the given number. Indexing starts at 1.

Source

fn on_click_copy_to_clipboard(self, text: impl Into<Cow<'static, str>>) -> Text

On click, copies the given text to clipboard.

Source

fn clear_click_event(self) -> Text

Clears the click_event property of the text. Property of the parent Text object will be used.

Source

fn on_hover_show_text(self, text: impl IntoText<'static>) -> Text

On mouse hover, shows the given text in a tooltip.

Source

fn clear_hover_event(self) -> Text

Clears the hover_event property of the text. Property of the parent Text object will be used.

Source

fn add_child(self, text: impl IntoText<'static>) -> Text

Adds a child Text object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl IntoText<'static> for &Cow<'static, str>

Source§

fn into_cow_text(self) -> Cow<'static, Text>

Source§

impl<'a> IntoText<'a> for &'a Cow<'_, Text>

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for &'static str

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for Cow<'a, Text>

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for Cow<'static, str>

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for bool

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for char

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for f32

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for f64

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for i8

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for i16

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for i32

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for i64

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for i128

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for isize

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for u8

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for u16

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for u32

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for u64

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for u128

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for usize

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a> IntoText<'a> for String

Source§

fn into_cow_text(self) -> Cow<'a, Text>

Source§

impl<'a, 'b, T, const N: usize> IntoText<'b> for [T; N]
where T: IntoText<'a>,

Source§

fn into_cow_text(self) -> Cow<'b, Text>

Source§

impl<'a, 'c, T, const N: usize> IntoText<'c> for &[T; N]
where T: IntoText<'a> + Clone,

Source§

fn into_cow_text(self) -> Cow<'c, Text>

Source§

impl<'b> IntoText<'b> for &String

Source§

fn into_cow_text(self) -> Cow<'b, Text>

Implementors§

Source§

impl<'a> IntoText<'a> for &'a Text

Source§

impl<'a> IntoText<'a> for Text