kifurushi: a little python library for your protocol implementation

a set of pillars maintaining a structure
Photo by Jon Tyson on Unsplash

Foreword

Installation

pip install kifurushi
poetry add kifurushi

Usage

  • You create a new protocol by inheriting the Packet class. In this example, the protocol Disney has three fields.
  • A two-bytes integer field called mickey whose default value is 2.
  • A one byte integer field called minnie whose default value is 3. You notice the hex keyword set to true. It is to tell that we prefer the hexadecimal representation when displaying this field information.
  • The last field is a four-byte field. It is slightly different from the first two (notice the Enum in the class name) . It takes a third mandatory argument which is an enum, or a dict mapping values to a literal representation easier to remember for the user.
  • The list of all fields is available here.
  • You can set packet attributes using the field name like on line 26.
  • To get the binary representation of a packet, you use its raw property (line 28).
  • To get a packet instance from raw bytes, we use the from_bytes class method (line 30).

--

--

--

Déserteur camerounais résidant désormais en France. Passionné de programmation, sport, de cinéma et mangas. J’écris en français et en anglais dû à mes origines.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Single Responsibility Principle and Context

Web development degrees are (practically) useless

Can we determine whether a user inputs a real or a fake email address?

Free Modbus Master Application Personal Statement

Static libraries in C

Governance on Cosmos

The First Time I Said I Love You To A Girl

Virtual Machines Azure

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin Tewouda

Kevin Tewouda

Déserteur camerounais résidant désormais en France. Passionné de programmation, sport, de cinéma et mangas. J’écris en français et en anglais dû à mes origines.

More from Medium

STRINGS AND INTEGERS IN P

Python : A Guide to Numbers

How to create a function in python to be used from the terminal

Everything You Need to Know About List Methods and List Comprehensions in Python.