|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
gRPC message with compression flag and payload More...
#include <frame.h>

Public Member Functions | |
| grpc_message ()=default | |
| Default constructor. | |
| grpc_message (std::vector< uint8_t > payload, bool is_compressed=false) | |
| Construct with data. | |
| auto | serialize () const -> std::vector< uint8_t > |
| Serialize message to bytes with length prefix. | |
| auto | serialized_size () const -> size_t |
| Get total serialized size including header. | |
| auto | empty () const -> bool |
| Check if message is empty. | |
| auto | size () const -> size_t |
| Get message size (payload only) | |
Static Public Member Functions | |
| static auto | parse (std::span< const uint8_t > input) -> Result< grpc_message > |
| Parse gRPC message from raw bytes. | |
Public Attributes | |
| bool | compressed = false |
| Whether payload is compressed. | |
| std::vector< uint8_t > | data |
| Message payload. | |
gRPC message with compression flag and payload
Represents a gRPC message as transmitted over HTTP/2. Format: | Compressed-Flag (1 byte) | Message-Length (4 bytes) | Message |
|
default |
Default constructor.
|
inlineexplicit |
Construct with data.
| payload | Message data |
| is_compressed | Whether data is compressed |
Definition at line 64 of file frame.h.
|
inline |
|
static |
Parse gRPC message from raw bytes.
| input | Raw byte data (header + payload) |
Parses a gRPC length-prefixed message from the input buffer.
Definition at line 14 of file frame.cpp.
References compressed, data, kcenon::network::protocols::grpc::default_max_message_size, kcenon::network::error, kcenon::network::protocols::grpc::grpc_header_size, kcenon::network::error_codes::common_errors::invalid_argument, and kcenon::network::protocols::grpc::ok.
Referenced by kcenon::network::protocols::grpc::grpc_client::impl::call_raw(), kcenon::network::protocols::grpc::client_stream_writer_impl::on_complete(), kcenon::network::protocols::grpc::bidi_stream_impl::read(), and kcenon::network::protocols::grpc::server_stream_reader_impl::read().

| auto kcenon::network::protocols::grpc::grpc_message::serialize | ( | ) | const -> std::vector<uint8_t> |
Serialize message to bytes with length prefix.
Serializes the message with a 5-byte header prefix.
Definition at line 67 of file frame.cpp.
References compressed, data, and kcenon::network::protocols::grpc::grpc_header_size.
Referenced by kcenon::network::protocols::grpc::grpc_client::impl::call_raw(), kcenon::network::protocols::grpc::grpc_client::impl::server_stream_raw(), kcenon::network::protocols::grpc::bidi_stream_impl::write(), and kcenon::network::protocols::grpc::client_stream_writer_impl::write().

|
inline |
Get total serialized size including header.
Definition at line 88 of file frame.h.
References data, and kcenon::network::protocols::grpc::grpc_header_size.
|
inline |
| bool kcenon::network::protocols::grpc::grpc_message::compressed = false |
Whether payload is compressed.
Definition at line 51 of file frame.h.
Referenced by parse(), and serialize().
| std::vector<uint8_t> kcenon::network::protocols::grpc::grpc_message::data |
Message payload.
Definition at line 52 of file frame.h.
Referenced by empty(), kcenon::network::protocols::grpc::client_stream_writer_impl::finish(), main(), parse(), serialize(), serialized_size(), and size().