TextComponent

Struct TextComponent 

Source
#[repr(transparent)]
pub struct TextComponent { pub text: Text, }

Fields§

§text: Text

Implementations§

Source§

impl TextComponent

Source

pub fn from_cow_text<'a>(cow: Cow<'a, Text>) -> Cow<'a, TextComponent>

Zero-copy cast from a Cow<Text> to a Cow<TextComponent>.

§Safety

This is safe because TextComponent is #[repr(transparent)] wrapper around Text.

Source

pub fn as_text(&self) -> &Text

Trait Implementations§

Source§

impl Clone for TextComponent

Source§

fn clone(&self) -> TextComponent

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TextComponent

Source§

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

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

impl Decode<'_> for TextComponent

Source§

fn decode(r: &mut &[u8]) -> Result<Self>

Reads this object from the provided byte slice. Read more
Source§

impl Encode for TextComponent

Source§

fn encode(&self, w: impl Write) -> Result<()>

Writes this object to the provided writer. Read more
Source§

fn encode_slice(slice: &[Self], w: impl Write) -> Result<()>
where Self: Sized,

Like Encode::encode, except that a whole slice of values is encoded. Read more
Source§

impl From<Text> for TextComponent

Source§

fn from(value: Text) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoText<'a> for TextComponent

Source§

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

Converts to a Text object, either owned or borrowed.
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.
Source§

impl PartialEq for TextComponent

Source§

fn eq(&self, other: &TextComponent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TextComponent

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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<'a, T> IntoTextComponent<'a> for T
where T: IntoText<'a>,

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.