pub struct JsonTextComponent(pub JsonComponent);Expand description
A text component encoded as JSON in a protocol string.
Since Java Edition 1.20.3, the vanilla implementation permits up to 262,144 UTF-16 code units when decoding but refuses to encode more than 32,767. See the text component format.
Tuple Fields§
§0: JsonComponentThe structured text component value.
Implementations§
Source§impl JsonTextComponent
impl JsonTextComponent
Sourcepub const MAX_DECODE_UTF16_CODE_UNITS: usize = 262_144
pub const MAX_DECODE_UTF16_CODE_UNITS: usize = 262_144
The maximum number of UTF-16 code units accepted while decoding.
Sourcepub const MAX_DECODE_BYTES: usize
pub const MAX_DECODE_BYTES: usize
The maximum decoded UTF-8 payload size, excluding its VarInt length prefix.
Sourcepub const MAX_DECODE_ENCODED_BYTES: usize
pub const MAX_DECODE_ENCODED_BYTES: usize
The maximum decoded size, including the VarInt length prefix.
Sourcepub const MAX_ENCODE_UTF16_CODE_UNITS: usize = 32_767
pub const MAX_ENCODE_UTF16_CODE_UNITS: usize = 32_767
The maximum number of UTF-16 code units permitted while encoding.
Vanilla Java Edition 1.20.3 and later still refuses to encode larger JSON components despite accepting them while decoding.
Sourcepub const MAX_ENCODE_BYTES: usize
pub const MAX_ENCODE_BYTES: usize
The maximum encoded UTF-8 payload size, excluding its VarInt length prefix.
Sourcepub const MAX_ENCODE_ENCODED_BYTES: usize
pub const MAX_ENCODE_ENCODED_BYTES: usize
The maximum encoded size, including the VarInt length prefix.
Sourcepub fn from_json_str(value: &str) -> Result<Self, CodecError>
pub fn from_json_str(value: &str) -> Result<Self, CodecError>
Parses and validates a text component from JSON without a length prefix.
On failure, the number of bytes of value is reported as
CodecError::bytes_processed.
§Errors
Returns a CodecError if value is invalid JSON, does not represent
a text component, or exceeds the supported nesting depth.
Trait Implementations§
Source§impl Clone for JsonTextComponent
impl Clone for JsonTextComponent
Source§fn clone(&self) -> JsonTextComponent
fn clone(&self) -> JsonTextComponent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more