Skip to main content

PacketRegistry

Struct PacketRegistry 

Source
pub struct PacketRegistry { /* private fields */ }
Expand description

Version-aware packet registry for decoding Minecraft protocol packets.

The registry dispatches raw packet bytes to the correct decoder based on the packet ID, connection state, and direction (serverbound/clientbound). It is constructed for a specific protocol version via PacketRegistry::for_version.

Currently supports Handshake, Status, and Login states. Configuration and Play will be added as their packets are generated.

Implementations§

Source§

impl PacketRegistry

Source

pub fn for_version(version: ProtocolVersion) -> Self

Creates a packet registry for the given protocol version.

Source

pub fn version(&self) -> ProtocolVersion

Returns the protocol version this registry was built for.

Source

pub fn decode_serverbound_handshake( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundHandshakePacket>

Decodes a serverbound Handshake packet from its ID and payload.

Source

pub fn decode_serverbound_status( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundStatusPacket>

Decodes a serverbound Status packet from its ID and payload.

Source

pub fn decode_clientbound_status( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundStatusPacket>

Decodes a clientbound Status packet from its ID and payload.

Source

pub fn decode_serverbound_login( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundLoginPacket>

Decodes a serverbound Login packet from its ID and payload.

Source

pub fn decode_clientbound_login( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundLoginPacket>

Decodes a clientbound Login packet from its ID and payload.

Source

pub fn decode_serverbound_configuration( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundConfigurationPacket>

Decodes a serverbound Configuration packet from its ID and payload.

Source

pub fn decode_clientbound_configuration( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundConfigurationPacket>

Decodes a clientbound Configuration packet from its ID and payload.

Source

pub fn decode_serverbound_play( &self, id: i32, buf: &mut &[u8], ) -> Result<ServerboundPlayPacket>

Decodes a serverbound Play packet from its ID and payload.

Source

pub fn decode_clientbound_play( &self, id: i32, buf: &mut &[u8], ) -> Result<ClientboundPlayPacket>

Decodes a clientbound Play packet from its ID and payload.

Trait Implementations§

Source§

impl Debug for PacketRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.