| 167 | }; |
| 168 | |
| 169 | auto encode(std::string_view msg) { |
| 170 | byte_buffer bytes; |
| 171 | using detail::to_network_order; |
| 172 | auto prefix = to_network_order(static_cast<uint32_t>(msg.size())); |
| 173 | auto prefix_bytes = as_bytes(make_span(&prefix, 1)); |
| 174 | bytes.insert(bytes.end(), prefix_bytes.begin(), prefix_bytes.end()); |
| 175 | auto msg_bytes = as_bytes(make_span(msg)); |
| 176 | bytes.insert(bytes.end(), msg_bytes.begin(), msg_bytes.end()); |
| 177 | return bytes; |
| 178 | } |
| 179 | |
| 180 | } // namespace |
| 181 |
no test coverage detected