Skip to main content

Packet serialization/deserialization in a Pythonic way.

Project description

päckel

Network protocol library. Handles packet serialization/deserialization in a Pythonic way.

Usage

  • Define a basic protocol :
import packel

class Ping(packel.Packet):
    text = packel.String()

class Pong(packel.Packet):
    is_hello = packel.Boolean()

protocol = packel.Protocol([Ping, Pong])
  • Use it to serialize and deserialize data :
request = Ping(text='hello')
serialized_bytes = protocol.serialize(request)

# ...

packet = protocol.deserialize(serialized_bytes)
if isinstance(packet, Ping):
    is_hello = packet.text == 'hello'
    response = Pong(is_hello=is_hello)
    # ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

packel-1.0.0.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

packel-1.0.0-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page