Skip to main content

Struct to model (dataclass) for python

Project description

Welcome

Struct-Model

Struct-Model is an annotations based wrapper for python's built-in Struct module.

from struct_model import StructModel, String, uInt4

class Form(StructModel):
    username: String(16)
    balance: uInt4
    
print(Form("Adam Bright", 12).pack())
# b'Adam Bright\x00\x00\x00\x00\x00\x00\x00\x00\x0c'
print(Form.unpack(b'Adam Bright\x00\x00\x00\x00\x00\x00\x00\x00\x0c').json())
# {"username": "Adam Bright", "balance": 12}

Installation

Poetry

poetry add struct-model-python

PIP

pip install struct-model-python

Requirements

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

struct-model-python-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

struct_model_python-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file struct-model-python-0.1.1.tar.gz.

File metadata

  • Download URL: struct-model-python-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.1 Darwin/21.2.0

File hashes

Hashes for struct-model-python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8b6ae00f6f373da4f61a7e22f3e68c94c1caf28237138a676f1883954da9ce42
MD5 655a0a1d6096bf41cd69d8bfae9f5af6
BLAKE2b-256 d2a29d3f1ad614b9f9574df47d1c99d6854ad271dc0b82387fa801102723e999

See more details on using hashes here.

File details

Details for the file struct_model_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for struct_model_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 552eac4a519835a9aa40c4aa8e38a4565b14042ca2c7d23362077b27aafe56c3
MD5 2ecccda1eb7828abce8b3615fe060fe4
BLAKE2b-256 b89777411b816342a8e07658234b89395218eed475da0d561af9f582b05cec73

See more details on using hashes here.

Supported by

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