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<FormattedText>
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§fn default() -> FormattedText
fn default() -> FormattedText
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for FormattedText
impl<'de> Deserialize<'de> for FormattedText
Source§fn deserialize<D>(
de: D,
) -> Result<FormattedText, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
de: D,
) -> Result<FormattedText, <D as Deserializer<'de>>::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§fn from(s: &Mutf8Str) -> FormattedText
fn from(s: &Mutf8Str) -> FormattedText
Converts to this type from the input type.
Source§impl From<&str> for FormattedText
impl From<&str> for FormattedText
Source§fn from(s: &str) -> FormattedText
fn from(s: &str) -> FormattedText
Converts to this type from the input type.
Source§impl From<String> for FormattedText
impl From<String> for FormattedText
Source§fn from(s: String) -> FormattedText
fn from(s: String) -> FormattedText
Converts to this type from the input type.
Source§impl FromNbtTag for FormattedText
impl FromNbtTag for FormattedText
fn from_nbt_tag(tag: NbtTag<'_, '_>) -> Option<FormattedText>
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) -> <FormattedText as IntoIterator>::IntoIter
fn into_iter(self) -> <FormattedText as IntoIterator>::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
fn read_from(buf: &mut Cursor<&[u8]>) -> Result<FormattedText, BufReadError>
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§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Forward to the method defined on the type
Any
.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Forward to the method defined on the type
Any
.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DynEq for T
impl<T> DynEq for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given [World
].