pub trait EncodedSize {
// Required method
fn encoded_size(&self) -> usize;
}Expand description
Predict the exact serialized byte count for pre-allocation.
Required Methods§
fn encoded_size(&self) -> usize
Implementations on Foreign Types§
Source§impl EncodedSize for bool
A boolean always occupies exactly one byte on the wire.
impl EncodedSize for bool
A boolean always occupies exactly one byte on the wire.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for f32
The encoded size is always
4 bytes, regardless of the value.
impl EncodedSize for f32
The encoded size is always 4 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for f64
The encoded size is always
8 bytes, regardless of the value.
impl EncodedSize for f64
The encoded size is always 8 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for i8
The encoded size is always
1 bytes, regardless of the value.
impl EncodedSize for i8
The encoded size is always 1 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for i16
The encoded size is always
2 bytes, regardless of the value.
impl EncodedSize for i16
The encoded size is always 2 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for i32
The encoded size is always
4 bytes, regardless of the value.
impl EncodedSize for i32
The encoded size is always 4 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for i64
The encoded size is always
8 bytes, regardless of the value.
impl EncodedSize for i64
The encoded size is always 8 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for u8
The encoded size is always
1 bytes, regardless of the value.
impl EncodedSize for u8
The encoded size is always 1 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for u16
The encoded size is always
2 bytes, regardless of the value.
impl EncodedSize for u16
The encoded size is always 2 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for u32
The encoded size is always
4 bytes, regardless of the value.
impl EncodedSize for u32
The encoded size is always 4 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for u64
The encoded size is always
8 bytes, regardless of the value.
impl EncodedSize for u64
The encoded size is always 8 bytes, regardless of the value.
fn encoded_size(&self) -> usize
Source§impl EncodedSize for String
Computes the wire size of a Minecraft protocol string.
impl EncodedSize for String
Computes the wire size of a Minecraft protocol string.
The total size is the VarInt-encoded length prefix plus the UTF-8 byte count. This enables exact buffer pre-allocation before encoding.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Returns the VarInt prefix size plus the string’s byte length.
Source§impl EncodedSize for Vec<u8>
Computes the wire size of a Minecraft protocol byte array.
impl EncodedSize for Vec<u8>
Computes the wire size of a Minecraft protocol byte array.
The total size is the VarInt-encoded length prefix plus the byte count. This enables exact buffer pre-allocation before encoding.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Returns the VarInt prefix size plus the array’s byte length.
Source§impl<T: EncodedSize + ?Sized> EncodedSize for Box<T>
impl<T: EncodedSize + ?Sized> EncodedSize for Box<T>
fn encoded_size(&self) -> usize
Implementors§
impl EncodedSize for NbtTag
Computes the wire size of an NbtTag as a network NBT root.
impl EncodedSize for NbtCompound
Computes the wire size of a network NBT root compound.
Includes the compound type byte (1) plus the compound payload size (entries + End tag).
impl EncodedSize for Angle
An Angle always occupies exactly 1 byte on the wire.
impl EncodedSize for BitSet
Computes the wire size of the BitSet.
The total size is the VarInt-encoded length prefix plus 8 bytes per long. This enables exact buffer pre-allocation before encoding.
impl EncodedSize for Identifier
Computes the wire size of the identifier in namespace:path format.
The total size includes the VarInt length prefix and the full
namespace:path UTF-8 byte count (including the colon separator).
impl EncodedSize for OpaqueBytes
impl EncodedSize for Position
A Position always occupies exactly 8 bytes on the wire (one packed i64).
impl EncodedSize for Slot
Computes the wire size of a Slot.
impl EncodedSize for TextComponent
Computes the wire size of a TextComponent as network NBT.
Converts to NbtCompound and delegates to its EncodedSize. This involves building the full NBT tree, so it is not free — use sparingly or cache the result when encoding multiple times.
impl EncodedSize for Uuid
A UUID always occupies exactly 16 bytes on the wire.
impl EncodedSize for VarInt
Computes the number of bytes this VarInt will occupy when encoded.
Returns 1-5 based on the unsigned magnitude of the value. Small positive values (0-127) take 1 byte, while negative values always take 5 bytes due to two’s complement sign extension.
impl EncodedSize for VarLong
Computes the number of bytes this VarLong will occupy when encoded.
Returns 1-10 based on the unsigned magnitude. Small positive values
(0-127) take 1 byte, i64::MAX takes 9, and negative values always
take 10 bytes.
impl EncodedSize for Vec2f
A Vec2f always occupies 8 bytes (2 × f32).
impl EncodedSize for Vec3f64
A Vec3f64 always occupies 24 bytes (3 × f64).
impl EncodedSize for Vec3f
A Vec3f always occupies 12 bytes (3 × f32).
impl EncodedSize for Vec3i16
A Vec3i16 always occupies 6 bytes (3 × i16).