Tweak text.rs

This commit is contained in:
Ryan 2022-04-17 17:05:13 -07:00
parent a997820b7a
commit f35d8e7b13

View file

@ -24,7 +24,7 @@ use crate::Identifier;
/// ## Example /// ## Example
/// With [`TextFormat`] in scope, you can write the following: /// With [`TextFormat`] in scope, you can write the following:
/// ``` /// ```
/// use server::text::{Color, Text, TextFormat}; /// use valence::text::{Color, Text, TextFormat};
/// ///
/// let txt = "The text is ".into_text() /// let txt = "The text is ".into_text()
/// + "Red".color(Color::RED) /// + "Red".color(Color::RED)
@ -42,6 +42,7 @@ use crate::Identifier;
/// ); /// );
/// ``` /// ```
#[derive(Clone, PartialEq, Default, Debug, Serialize, Deserialize)] #[derive(Clone, PartialEq, Default, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Text { pub struct Text {
#[serde(flatten)] #[serde(flatten)]
content: TextContent, content: TextContent,
@ -70,11 +71,9 @@ pub struct Text {
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
insertion: Option<Cow<'static, str>>, insertion: Option<Cow<'static, str>>,
#[serde(rename = "clickEvent")]
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
click_event: Option<ClickEvent>, click_event: Option<ClickEvent>,
#[serde(rename = "hoverEvent")]
#[serde(default, skip_serializing_if = "Option::is_none")] #[serde(default, skip_serializing_if = "Option::is_none")]
hover_event: Option<HoverEvent>, hover_event: Option<HoverEvent>,
@ -284,7 +283,7 @@ enum TextContent {
// TODO: nbt // TODO: nbt
} }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct Color { pub struct Color {
pub r: u8, pub r: u8,
pub g: u8, pub g: u8,