pub struct EncodedPacket {
pub encoded_data: Arc<FrontVec>,
}Expand description
Represents an encoded clientbound packet, optionally applying compression based on threshold and level.
§Packet Size Limits
- Maximum packet size: 2097151 bytes (2^21 - 1, max 3-byte
VarInt) - Maximum uncompressed size for compressed packets: 8388608 bytes (2^23)
- Length field must not exceed 3 bytes
§Packet Encoding Format
Without Compression:
[Length: VarInt] Length of (Packet ID + Data)
[Packet ID: VarInt] Protocol ID from packet report
[Data: Byte Array] Packet payloadWith Compression (size >= threshold):
[Length: VarInt] Length of (Data Length + compressed data)
[Data Length: VarInt] Length of uncompressed (Packet ID + Data)
[Compressed Data] zlib compressed (Packet ID + Data)With Compression (size < threshold):
[Length: VarInt] Length of (Data Length + uncompressed data)
[Data Length: VarInt] 0 to indicate uncompressed
[Packet ID: VarInt] Protocol ID from packet report
[Data: Byte Array] Uncompressed packet payloadCompression is only applied when:
- Compression is enabled via Set Compression packet
- The uncompressed data length meets/exceeds the threshold
- The threshold is non-negative
Fields§
§encoded_data: Arc<FrontVec>The encoded data.
Implementations§
Source§impl EncodedPacket
impl EncodedPacket
fn from_data_uncompressed(packet_data: FrontVec) -> Result<Self, PacketError>
fn from_packet_data( packet_data: FrontVec, compression: CompressionInfo, ) -> Result<Self, PacketError>
Sourcepub fn from_bare<P: ClientPacket>(
packet: P,
compression: Option<CompressionInfo>,
protocol: ConnectionProtocol,
) -> Result<Self, PacketError>
pub fn from_bare<P: ClientPacket>( packet: P, compression: Option<CompressionInfo>, protocol: ConnectionProtocol, ) -> Result<Self, PacketError>
Creates a new EncodedPacket from a bare packet.
§Errors
- If the packet fails to write.
- If the packet fails to compress.
fn write_vec<P: ClientPacket>( packet: P, protocol: ConnectionProtocol, ) -> Result<FrontVec, PacketError>
fn from_data( buf: FrontVec, compression: Option<CompressionInfo>, ) -> Result<Self, PacketError>
Trait Implementations§
Source§impl Clone for EncodedPacket
impl Clone for EncodedPacket
Source§fn clone(&self) -> EncodedPacket
fn clone(&self) -> EncodedPacket
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for EncodedPacket
impl RefUnwindSafe for EncodedPacket
impl Send for EncodedPacket
impl Sync for EncodedPacket
impl Unpin for EncodedPacket
impl UnsafeUnpin for EncodedPacket
impl UnwindSafe for EncodedPacket
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>