#packet-stream #derive #default #codec #enums #encode #packetize

macro no-std packetize_derive

encode and decode your packet with stream channel

98 breaking releases

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

#5 in #packet-stream

Download history 177/week @ 2024-09-25 13/week @ 2024-10-02 3/week @ 2024-10-09 152/week @ 2024-10-16 54/week @ 2024-10-23 7/week @ 2024-10-30 2/week @ 2024-11-06 229/week @ 2024-11-27 86/week @ 2024-12-04 279/week @ 2024-12-11 124/week @ 2024-12-18 21/week @ 2024-12-25 8/week @ 2025-01-08

158 downloads per month
Used in packetize

MIT license

20KB
401 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

~210–650KB
~15K SLoC