aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src/component.rs')
-rwxr-xr-xazalea-chat/src/component.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 9362a66b..95387248 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -6,14 +6,15 @@ use crate::{
};
use azalea_buf::{BufReadError, McBufReadable, McBufWritable};
use once_cell::sync::Lazy;
-use serde::{de, Deserialize, Deserializer};
+use serde::{de, Deserialize, Deserializer, Serialize};
use std::{
fmt::Display,
io::{Cursor, Write},
};
/// A chat component, basically anything you can see in chat.
-#[derive(Clone, Debug, PartialEq)]
+#[derive(Clone, Debug, PartialEq, Serialize)]
+#[serde(untagged)]
pub enum Component {
Text(TextComponent),
Translatable(TranslatableComponent),
@@ -262,11 +263,10 @@ impl McBufReadable for Component {
}
impl McBufWritable for Component {
- fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
- // let json = serde_json::to_string(self).unwrap();
- // json.write_into(_buf);
- // Ok(())
- todo!()
+ fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ let json = serde_json::to_string(self).unwrap();
+ json.write_into(buf)?;
+ Ok(())
}
}