pub struct ChatType {
pub chat: ChatDecoration,
pub narration: ChatDecoration,
}Expand description
Describes a direct chat type that a message can be sent with.
The chat decoration is encoded first and the narration decoration second:
ChatDecoration(chat) + ChatDecoration(narration)Both fields use the same decoration structure, but may use different translation keys, parameter orders, and styles.
§Examples
use fastnbt::nbt;
use mcproto_types::{
ChatDecoration, ChatType, ChatTypeParameter, Nbt, PrefixedArray,
PrefixedString, TypeCodec,
};
let value = ChatType::new(
ChatDecoration::new(
PrefixedString("chat.type.text".into()),
PrefixedArray(vec![ChatTypeParameter::Sender, ChatTypeParameter::Content]),
Nbt(nbt!({})),
),
ChatDecoration::new(
PrefixedString("chat.type.text.narrate".into()),
PrefixedArray(vec![ChatTypeParameter::Sender, ChatTypeParameter::Content]),
Nbt(nbt!({})),
),
);
let mut encoded = Vec::new();
value.encode(&mut encoded)?;
let mut input = encoded.as_slice();
assert_eq!(ChatType::decode(&mut input)?, value);
assert!(input.is_empty());Fields§
§chat: ChatDecorationDecoration used for the normal chat presentation.
narration: ChatDecorationDecoration used for narration.
Implementations§
Source§impl ChatType
impl ChatType
Sourcepub const fn new(chat: ChatDecoration, narration: ChatDecoration) -> Self
pub const fn new(chat: ChatDecoration, narration: ChatDecoration) -> Self
Creates a direct chat type from its chat and narration decorations.
Trait Implementations§
impl StructuralPartialEq for ChatType
Auto Trait Implementations§
impl Freeze for ChatType
impl RefUnwindSafe for ChatType
impl Send for ChatType
impl Sync for ChatType
impl Unpin for ChatType
impl UnsafeUnpin for ChatType
impl UnwindSafe for ChatType
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§impl<T> ContextualCodec for Twhere
T: TypeCodec,
impl<T> ContextualCodec for Twhere
T: TypeCodec,
Source§fn encode_with_context(
&self,
writer: &mut impl Write,
_context: &Context,
) -> Result<(), CodecError>
fn encode_with_context( &self, writer: &mut impl Write, _context: &Context, ) -> Result<(), CodecError>
Encodes this value using context supplied by its enclosing structure.
Source§fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
fn decode_with_context(
reader: &mut impl Read,
_context: &Context,
) -> Result<T, CodecError>where
T: Sized,
Decodes this value using context supplied by its enclosing structure.