pub enum FormattedText {
Text(TextComponent),
Translatable(TranslatableComponent),
}
Expand description
A chat component, basically anything you can see in chat.
Variants§
Text(TextComponent)
Translatable(TranslatableComponent)
Implementations§
Source§impl FormattedText
impl FormattedText
A chat component
pub fn get_base_mut(&mut self) -> &mut BaseComponent
pub fn get_base(&self) -> &BaseComponent
Sourcepub fn to_ansi(&self) -> String
pub fn to_ansi(&self) -> String
Convert this component into an ANSI string, so you can print it to your terminal and get styling.
This is technically a shortcut for
FormattedText::to_ansi_with_custom_style
with a default Style
colored white.
§Examples
use azalea_chat::FormattedText;
use serde::de::Deserialize;
let component = FormattedText::deserialize(&serde_json::json!({
"text": "Hello, world!",
"color": "red",
})).unwrap();
println!("{}", component.to_ansi());
Sourcepub fn to_ansi_with_custom_style(&self, default_style: &Style) -> String
pub fn to_ansi_with_custom_style(&self, default_style: &Style) -> String
Convert this component into an ANSI string.
This is the same as FormattedText::to_ansi
, but you can specify a
default Style
to use.
Source§impl FormattedText
impl FormattedText
pub fn from_nbt_compound(compound: NbtCompound<'_, '_>) -> Option<Self>
Trait Implementations§
Source§impl Clone for FormattedText
impl Clone for FormattedText
Source§fn clone(&self) -> FormattedText
fn clone(&self) -> FormattedText
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for FormattedText
impl Debug for FormattedText
Source§impl Default for FormattedText
impl Default for FormattedText
Source§impl<'de> Deserialize<'de> for FormattedText
impl<'de> Deserialize<'de> for FormattedText
Source§fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(de: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for FormattedText
impl Display for FormattedText
Source§impl From<&Mutf8Str> for FormattedText
impl From<&Mutf8Str> for FormattedText
Source§impl From<&str> for FormattedText
impl From<&str> for FormattedText
Source§impl From<String> for FormattedText
impl From<String> for FormattedText
Source§impl FromNbtTag for FormattedText
impl FromNbtTag for FormattedText
fn from_nbt_tag(tag: NbtTag<'_, '_>) -> Option<Self>
fn from_optional_nbt_tag( tag: Option<NbtTag<'_, '_>>, ) -> Result<Option<Self>, DeserializeError>
Source§impl Hash for FormattedText
impl Hash for FormattedText
Source§impl IntoIterator for FormattedText
impl IntoIterator for FormattedText
Source§fn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Recursively call the function for every component in this component
Source§type Item = FormattedText
type Item = FormattedText
The type of the elements being iterated over.
Source§type IntoIter = IntoIter<<FormattedText as IntoIterator>::Item>
type IntoIter = IntoIter<<FormattedText as IntoIterator>::Item>
Which kind of iterator are we turning this into?
Source§impl McBufReadable for FormattedText
impl McBufReadable for FormattedText
Source§impl McBufWritable for FormattedText
impl McBufWritable for FormattedText
Source§impl PartialEq for FormattedText
impl PartialEq for FormattedText
Source§impl Serialize for FormattedText
impl Serialize for FormattedText
Source§impl Serialize for FormattedText
impl Serialize for FormattedText
fn to_compound(self) -> NbtCompound
fn to_nbt(self) -> BaseNbt
impl Eq for FormattedText
impl StructuralPartialEq for FormattedText
Auto Trait Implementations§
impl Freeze for FormattedText
impl RefUnwindSafe for FormattedText
impl Send for FormattedText
impl Sync for FormattedText
impl Unpin for FormattedText
impl UnwindSafe for FormattedText
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)