Commit Graph

9 Commits

Author SHA1 Message Date
Alexander Medvedev
4afe60aca9 chore: i'm back 2026-02-21 20:52:37 +01:00
Alexander Medvedev
b58822319d fix: CI 2026-01-28 23:40:48 +01:00
Alexander Medvedev
fb13004b47 fix: apply clippy lints to workspace
also add contributors to /pumpkin command

Co-Authored-By: Fyor <90567841+fyordev@users.noreply.github.com>
Co-Authored-By: MartV0 <34748938+martv0@users.noreply.github.com>
Co-Authored-By: FabseGP <fabsegp@fabseman.space>
2026-01-28 00:52:47 +01:00
unschlagbar
2e2236bf3b Bedrock player joining (#1063)
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-26 17:31:00 +02:00
unschlagbar
8d934e31c7 First valid Raknet Frame set Packet :) (#983)
* hhlzuui

* gg

* reufef

* fix

---------

Co-authored-by: unschlagbar <adrian@kuhlmann@gmx.de>
2025-07-01 14:04:23 +02:00
Omar Afet
1e8687a642 Implement Missing (De)Serializations for pumpkin-protocol (#863)
* feat(protocol): Implement char serialization and deserialization

This commit introduces support for serializing and deserializing individual characters within the pumpkin-protocol. Characters are handled as big-endian u32 Unicode scalar values.

Key changes:
- Implemented `Serializer::serialize_char` to write a `char` as a `u32`.
- Implemented `Deserializer::deserialize_char` to read a `u32` and convert it to a `char`, including validation for invalid scalar values.
- Added a new test suite `test_char_reserialize` with cases for ASCII, multi-byte Unicode characters (e.g., 'Ω'), and characters requiring 4-byte UTF-8 representation (e.g., '🎃').
- Corrected warnings related to unused mutable variables in the new tests.

Additionally, to support the testing and building of related crates:
- fix(build): Enabled the `io-util` feature for the `tokio` workspace dependency in the root `Cargo.toml`. This resolved compilation errors in the `pumpkin-world` crate by providing necessary async I/O utilities like `AsyncReadExt` and `AsyncWriteExt`.

* feat(protocol): Implement i128/u128 serialization and deserialization

This commit adds support for serializing and deserializing 128-bit integer types (i128 and u128) in the pumpkin-protocol. These values are written and read as 16 bytes in big-endian order.

Key changes:
- Implemented `Serializer::serialize_i128` and `Serializer::serialize_u128` to write i128/u128 values.
- Added `NetworkReadExt::get_i128_be` and `NetworkReadExt::get_u128_be` for reading these types.
- Implemented `Deserializer::deserialize_i128` and `Deserializer::deserialize_u128`.
- Added new test cases `test_i128_reserialize` and `test_u128_reserialize` to ensure correctness for both positive and negative i128 values, and positive u128 values.

* feat(protocol): Implement unit type (de)serialization

This commit introduces serialization and deserialization logic for Rust's unit type `()` and unit structs.

- `Serializer::serialize_unit` now correctly writes no bytes for unit types, as they carry no value.
- `Deserializer::deserialize_unit` and `Deserializer::deserialize_unit_struct` are implemented to
  consume no input and correctly reconstruct unit types/structs.
- Added `test_unit_reserialize` to verify that serializing and deserializing unit structs, both standalone and as fields within other structs, behaves as expected (i.e., no bytes are written or read for the unit components).

* feat(protocol): Implement enum (de)serialization for all variant types

This commit introduces comprehensive support for serializing and
deserializing Rust enums, including unit, newtype, tuple, and
struct variants.

Key changes:
- `serializer.rs`:
    - Implemented `serialize_struct_variant` to correctly write the
      variant index (as a VarInt) and then delegate to the
      `SerializeStructVariant` trait for field serialization.
    - Implemented `SerializeStructVariant` to serialize individual
      fields of a struct variant.
- `deserializer.rs`:
    - Implemented `deserialize_enum` to use `visitor.visit_enum`.
    - Implemented `EnumAccess` to read the variant index (as a VarInt,
      converted to u32) and deserialize the correct variant.
    - Implemented `VariantAccess` to handle deserialization of
      unit, newtype, tuple, and struct variants.
- `ser/mod.rs`:
    - Added `test_enum_reserialize` to thoroughly test (de)serialization
      of enums with unit, newtype (e.g., `Enum::B(i32)`), and struct
      variants (e.g., `Enum::C { field: T }`).

This ensures that enums with various structures can be reliably
transmitted over the network protocol.

* cargo fmt

* feat(protocol): Implement (de)serialization for tuple structs

This commit adds support for serializing and deserializing tuple
structs within the network protocol.

Key changes:
- `serializer.rs`:
    - `serialize_tuple_struct` in the main serializer now delegates
      to the `SerializeTupleStruct` trait implementation.
    - Implemented `SerializeTupleStruct` to serialize fields of a
      tuple struct sequentially.
    - Updated `SerializeTupleVariant::serialize_field` to correctly
      serialize tuple variant fields.
- `deserializer.rs`:
    - Implemented `deserialize_tuple_struct` to reuse the existing
      `deserialize_tuple` logic, as their serialization format is
      identical.
- `ser/mod.rs`:
    - Added `test_tuple_struct_reserialize` to verify the correct
      (de)serialization of tuple structs.

These changes ensure that tuple structs are handled correctly by the
protocol.

* feat(protocol): Implement (de)serialization for maps

This commit introduces support for serializing and deserializing
maps (specifically `std::collections::HashMap`) within the network
protocol.

Key changes:
- `serializer.rs`:
    - `serialize_map` now requires a known length for the map and
      writes this length as a VarInt before serializing key-value
      pairs.
    - Implemented `ser::SerializeMap` to handle the sequential
      serialization of map keys and values.
- `deserializer.rs`:
    - `deserialize_map` reads the VarInt length prefix.
    - Implemented `de::MapAccess` to deserialize key-value pairs
      according to the read length.
- `ser/mod.rs`:
    - Added `test_map_reserialize` to verify the correct
      (de)serialization of `HashMap<String, i32>`, including
      empty maps and maps with multiple entries.

These changes enable generic map types to be transmitted via the
protocol, with their length explicitly prefixed.
2025-06-08 12:00:45 +02:00
Alexander Medvedev
575f17948f Inline format arguments
Looks much nicer and more readable
2025-05-10 15:22:06 +02:00
kralverde
91ef79325a Network Serialization Quality of Life and Safety Improvements (#701) 2025-04-07 07:59:00 -10:00
kralverde
b9d9bacf8c Abstract networking to streamline code and avoid creating a new buffer for (de)compression. (#607) 2025-03-20 06:23:25 -10:00