1#ifndef NANOMMO_PROTOCOL_FRAMING_H_
2#define NANOMMO_PROTOCOL_FRAMING_H_
9#include "absl/status/status.h"
10#include "google/protobuf/message_lite.h"
19std::string
Header(std::size_t size);
22std::string
Frame(
const google::protobuf::MessageLite& message);
26 void Append(std::string_view bytes);
30 std::optional<std::string>
Next();
32 const absl::Status&
status()
const {
return status_; }
void Append(std::string_view bytes)
std::optional< std::string > Next()
const absl::Status & status() const
constexpr std::size_t kHeaderSize
std::string Header(std::size_t size)
constexpr std::size_t kMaxMessageSize
Anything bigger is garbage. Without a cap, we might buffer up to 4 GB.
std::string Frame(const google::protobuf::MessageLite &message)
The size goes in front, as four bytes in network byte order.