Functions to inspect packet state without modifying it.
◆ YAPB_check_complete()
| bool YAPB_check_complete |
( |
const uint8_t * | data, |
|
|
size_t | len ) |
Check if a receive buffer contains a complete YAPB packet.
Reads the 4-byte header to determine the expected packet length, then checks if the buffer contains at least that many bytes. Useful for framing packets from a stream (e.g., TCP socket).
- Parameters
-
| data | Raw data buffer (may be a partial packet). |
| len | Number of bytes available in the buffer. |
- Returns
- true if the buffer contains a complete packet, false otherwise.
◆ YAPB_get_buffer()
| const uint8_t * YAPB_get_buffer |
( |
const YAPB_Packet_t * | pkt, |
|
|
size_t * | out_len ) |
Get a const pointer to the packet's backing buffer and its length.
In read mode, returns the buffer and the packet length from the header. In write mode, returns the buffer and its length only after YAPB_finalize() has been called; returns NULL if the packet has not been finalized.
- Parameters
-
| pkt | Packet to query. |
| out_len | Output: packet length in bytes. May be NULL. |
- Returns
- Pointer to the buffer, or NULL if pkt is NULL or not finalized in write mode.
◆ YAPB_get_elem_count()
Count the number of elements in a packet.
Scans the packet from the header without advancing the read position. Nested packets count as a single element.
- Parameters
-
| pkt | Packet in read mode. |
| out_count | Output: number of elements. |
- Returns
- YAPB_OK on success, error code otherwise.
◆ YAPB_get_error()
Get the sticky error state of a packet.
Returns the current error state. A non-negative value means no error has occurred (YAPB_OK or YAPB_STS_COMPLETE).
- Parameters
-
- Returns
- YAPB_OK or YAPB_STS_COMPLETE if no error, negative error code otherwise.
◆ YAPB_Result_str()
Get a human-readable string for a result code.
- Parameters
-
- Returns
- Static string description (never NULL).