#packet #codec #packet-stream #websocket #tcp #minecraft #decoding

nightly no-std packetize

encode and decode your packet with stream channel

95 breaking releases

new 0.102.0 Dec 23, 2024
0.99.0 Nov 30, 2024
0.51.0 Jul 30, 2024

#803 in Encoding

Download history 146/week @ 2024-09-15 102/week @ 2024-09-22 46/week @ 2024-09-29 1/week @ 2024-10-06 191/week @ 2024-10-20 9/week @ 2024-10-27 3/week @ 2024-11-03 149/week @ 2024-11-24 102/week @ 2024-12-01 196/week @ 2024-12-08 102/week @ 2024-12-15 117/week @ 2024-12-22

666 downloads per month

MIT license

9KB
71 lines

packetize

  • Supports fast packet encoding and decoding for network packets.
  • Features packet framing with macros.
  • Designed for multiple packet formats (e.g., WebSocket, Minecraft, TCP)

#[packet_stream]
#[derive(Default)]
pub enum ConnectionState {
    #[default]
    HandShake(#[change_state_to(Idle)] HandShakeC2s),
    Idle(
        RoomListRequestC2s,
        RoomListResponseS2c<'_>,
        RoomJoinRequestC2s,
        RoomCreateRequestC2s,
        RoomJoinResponseS2c<'_>,
        RoomCreateResponseS2c<'_>,
        #[change_state_to(Conf)] RoomJoinedAckC2s,
    ),
    Conf(
        #[change_state_to(Disconnected)] DisconnectedConfS2c,
        ChatConfS2c,
        ChatConfC2s,
        GameStartS2c,
        #[change_state_to(Play)] GameStartAckC2s,
        LeaveRoomConfC2s,
        LeaveRoomConfS2c,
        #[change_state_to(Idle)] LeaveRoomConfAckS2c,
        #[change_state_to(Idle)] LeaveRoomConfAckC2s,
    ),
    Play(
        #[change_state_to(Disconnected)] DisconnectedPlayS2c,
        ChatPlayC2s,
        ChatPlayS2c,
        LeaveRoomPlayC2s,
        LeaveRoomPlayS2c,
        #[change_state_to(Idle)] LeaveRoomPlayAckS2c,
        #[change_state_to(Idle)] LeaveRoomPlayAckC2s,
    ),
    Disconnected,
}

Dependencies

~1–1.6MB
~34K SLoC