module Raft::RPC::Codec

Overview

TLV (Type-Length-Value) binary serialization for Raft RPC messages.

Wire format: [type: 1 byte][length: 4 bytes BigEndian][payload: N bytes]

Strings are length-prefixed with UInt16 BE, byte arrays with UInt32 BE, booleans as a single byte (0 or 1), and integers as big-endian fixed-width.

Defined in:

raft/rpc/codec.cr

Class Method Summary

Class Method Detail

def self.decode(io : IO) : Message #

Reads a TLV frame from io and returns the decoded RPC message.

Raises Raft::Error on unexpected EOF or unknown type tag.


[View source]
def self.encode(message : Message, io : IO) : Nil #

Encodes an RPC message as a TLV frame and writes it to io.


[View source]
def self.encode(message : Message) : Bytes #

Encodes an RPC message and returns the TLV frame as Bytes.


[View source]