|
ORE Studio 0.0.4
|
Complete frame with header and payload. More...
#include <frame.hpp>

Public Member Functions | |
| frame (message_type type, std::uint32_t sequence, std::vector< std::byte > payload, compression_type compression=compression_type::none) | |
| frame (message_type type, std::uint32_t sequence, std::uint32_t correlation_id, std::vector< std::byte > payload, compression_type compression=compression_type::none) | |
| std::uint32_t | correlation_id () const |
| Get the correlation ID for request/response matching. | |
| const frame_header & | header () const |
| Get the frame header. | |
| const std::vector< std::byte > & | payload () const |
| Get the raw payload (compressed if compression is enabled). | |
| compression_type | compression () const |
| Get the compression type used for the payload. | |
| std::expected< std::vector< std::byte >, error_code > | decompressed_payload () const |
| Decompress and return the payload. | |
| std::vector< std::byte > | serialize () const |
| Serialize frame to bytes. | |
| std::expected< void, error_code > | validate () const |
| Validate frame integrity. | |
Static Public Member Functions | |
| static std::expected< frame_header, error_code > | deserialize_header (std::span< const std::byte > data, bool skip_version_check=false) |
| Deserialize and validate header from bytes. | |
| static std::expected< frame, error_code > | deserialize (const frame_header &header, std::span< const std::byte > data) |
| Deserialize complete frame using a pre-parsed header. | |
Complete frame with header and payload.
| std::expected< std::vector< std::byte >, error_code > decompressed_payload | ( | ) | const |
Decompress and return the payload.
If no compression was used, returns a copy of the raw payload.

| std::vector< std::byte > serialize | ( | ) | const |
Serialize frame to bytes.
Calculates CRC32 over header (excluding CRC field) and payload, then serializes to network byte order.

|
static |
Deserialize and validate header from bytes.
Validates magic number, version, message type, reserved fields, and payload size. Does NOT validate CRC as that requires the full frame. Returns the validated header which can be used to determine how much payload to read.
| data | The data buffer containing the header |
| skip_version_check | If true, skips protocol version validation. This is useful during handshake to allow the server to send a proper version mismatch response instead of rejecting the frame immediately. |

|
static |
Deserialize complete frame using a pre-parsed header.
Takes the header from deserialize_header() and the complete buffer (header + payload). Validates CRC32 checksum over the entire frame. Returns error if validation fails.

| std::expected< void, error_code > validate | ( | ) | const |
Validate frame integrity.
Checks magic number, version compatibility, and CRC.