puzzlebox
Loading...
Searching...
No Matches
Message

Message (de)serialization. More...

Detailed Description

Functions

pb_buf_t pb_msg_write (const pb_msg_t *msg)
 Serialize a message into a binary buffer.
 
pb_msg_tpb_msg_read (const pb_buf_t *buf)
 Read a binary buffer and attempt to deserialize it as a puzzle bus message.
 
void pb_msg_free (pb_msg_t *msg)
 Recursively free fields of a pb_msg_t.
 

Function Documentation

◆ pb_msg_free()

void pb_msg_free ( pb_msg_t * msg)
Note
The msg pointer itself is also free'd by this function. You should set it to NULL afterwards to avoid confusion.

◆ pb_msg_read()

pb_msg_t * pb_msg_read ( const pb_buf_t * buf)
Note
This function allocates a pb_msg_t pointer that should be free'd using pb_msg_free()
Parameters
bufBinary data to interpret as puzzle bus message
Returns
pb_msg_t pointer containing the deserialized message, or NULL if serialization failed

◆ pb_msg_write()

pb_buf_t pb_msg_write ( const pb_msg_t * msg)
Note
This function allocates a pb_buf_t that should be free'd using pb_buf_free()
Parameters
msgMessage to serialize
Warning
The type of msg->cmd is inferred from msg->type. If the message is not correctly formatted, this function may cause undefined behavior. If possible, use functions from Send instead.
Returns
pb_buf_t containing the serialized message, or an empty struct if serialization failed