mc_protocol v0.0.2 McProtocol.Packet behaviour

Handles encoding and decoding of packets on the lowest level.

packet bytes <-> packet struct

Summary

Functions

Gets the packet module for the given direction, mode and id combination

Gets the packet id for the given packet module

Functions

id_module(direction, mode, id)

Specs

id_module(atom, atom, non_neg_integer) :: module

Gets the packet module for the given direction, mode and id combination.

The returned module will have this module as it’s behaviour.

module_id(module)

Specs

module_id(module) :: non_neg_integer

Gets the packet id for the given packet module.

read(direction, state, data)
read(direction, state, id, data)
write(struct)

Callbacks

direction()

Specs

direction :: atom
id()

Specs

id :: non_neg_integer
name()

Specs

name :: atom
read(binary)

Specs

read(binary) :: struct
state()

Specs

state :: atom
structure()

Specs

structure :: term
write(struct)

Specs

write(struct) :: iolist