Builds MoldUDP64 packets.
More...
#include <packet_builder.h>
Builds MoldUDP64 packets.
Usage:
- Call reset() to write the sequence number to the header.
- Add messages with try_add() until all are added, or it returns false (packet full per the configured MTU).
- Call finalize() to write the message count to the header and get the completed packet as a span of iovecs
◆ PacketBuilder()
| imr::mold::PacketBuilder::PacketBuilder |
( |
const Config & |
cfg | ) |
|
|
explicit |
- Exceptions
-
| std::invalid_argument | if cfg.session is not 10 characters |
| std::invalid_argument | if cfg.MTU less than the size of a MoldUDP64 header (20 bytes) |
◆ try_add()
| bool imr::mold::PacketBuilder::try_add |
( |
std::span< const char > |
message | ) |
|
|
noexcept |
Adds a message to the messge block.
- Returns
- false without adding message if wouldn't fit under configured MTU.
◆ finalize()
| std::span< iovec > imr::mold::PacketBuilder::finalize |
( |
| ) |
|
|
noexcept |
Writes the message count to the header and returns header + message block as iovecs.
◆ reset()
Writes sequence number for new packet to header and clears the message block.
◆ message_count()
Number of messages added since last reset().
◆ session()
| std::string_view imr::mold::PacketBuilder::session |
( |
| ) |
const |
|
noexcept |
Returns the configured MoldUDP64 session from header.
◆ min_message_size
| constexpr auto imr::mold::PacketBuilder::min_message_size {14} |
|
staticconstexpr |
The documentation for this class was generated from the following file: