v1.1.0¶
- Date:
January 1st, 2025
Changes¶
Drop support for Python 3.7.
- Implement an asynchronous unpacking API.
This allows users to unpack asynchronously using coroutines and the
awaitsyntax, which may in certain cases be necessary or otherwise desirable.- Where there is something that involves unpacking, there will be an asynchronous version of it suffixed with
_async, including the following: The
Type.unpack_async()method.The
Packet.unpack_async()method.The new functions in the
testmodule.
- Where there is something that involves unpacking, there will be an asynchronous version of it suffixed with
All
Types in Pak provide both the synchronous and asynchronous unpacking APIs, however customTypes are empowered to only provide one or the other, as often only one will be relevant to a certain usecase.
- Add
DeferringType. This allows a
Typeto defer its behavior to anotherTypeof its choosing depending on the relevantType.Context. This is useful, for instance, if you are supporting multiple versions of a protocol which might have different fields act like differentTypes depending on the protocol version.
- Add
- Improve customizing the endianness of
StructType. - The following methods were added to be able to tersely specify the desired endianness of a
StructType:
- The following methods were added to be able to tersely specify the desired endianness of a
This allows users to, for instance, call
pak.UInt16.big_endian()in order to use a big-endianUInt16, instead of the default little-endian version.
- Improve customizing the endianness of
- Add
LEB128.LimitedandULEB128.Limited.
- Add
- Reorder the bases of the returned class of
Packet.GenericWithID()to have more intuitive behavior. The
datafield fromGenericPacketis now situated at the end of thePacket, so that it will capture any remaining uncaptured data after the rest of the fields.
- Reorder the bases of the returned class of
- Give
EmptyTypean alignment of1. This better allows fields to be effectively “disabled” in an aligned context, such as when using
AlignedPacket.
- Give
Give
RawBytean alignment of1.- Refactor
Arrayto use specialized subclasses. - These specialized subclasses are:
- Refactor
- Refactor
Optionalto use specialized subclasses. - These specialized subclasses are:
- Refactor
- Add
Type.UnsuppressedError. Exceptions which inherit from
Type.UnsuppressedErrorindicate unambiguous errors in logic, which should not be suppressed by certainTypefacilities likeArray.UnboundedandOptional.Unchecked.
- Add
Types in Pak now more consistently raise errors if they are unable to read enough data when unpacking.- Make the
Type.prepare_types()decorator remove all parameter annotations ofTypefrom its decorated function. This prevents potentially confusing annotations of
Typefrom leaking out into documentation or other tools where those annotations may be misinterpreted. For instance, they could be mistaken as type hints. Parameter annotations ofTypewhen usingType.prepare_types()are only internally relevant, and should not be shown externally.
- Make the
Restrict certain function parameters to being positional-only in order to better enforce caching.
Fix typo in the name of
PacketHandler.unregister_packet_listener(), which was previously namedunregsiter_packet_listener.