Add RequestInfo/ResponseInfo with MAC address

This commit is contained in:
Ian Gulliver
2026-04-04 15:00:16 +09:00
parent 46af5becfe
commit d2b9a2e2aa
6 changed files with 67 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <expected>
@@ -366,6 +367,9 @@ public:
pack_result pack(const std::vector<uint8_t> &v) { return pack_bin(v); }
template <size_t N>
pack_result pack(const std::array<uint8_t, N> &v) { return pack_bin(v); }
template <typename... Ts>
pack_result pack(const std::tuple<Ts...> &t) {
auto r = pack_array(sizeof...(Ts));
@@ -725,6 +729,15 @@ inline result<parser> unpack(const parser &p, std::string &out) {
return p.next();
}
template <size_t N>
result<parser> unpack(const parser &p, std::array<uint8_t, N> &out) {
auto v = p.get_binary_view();
if (!v) return std::unexpected(v.error());
if (v->size() != N) return std::unexpected(error_code::type_error);
std::copy(v->begin(), v->end(), out.begin());
return p.next();
}
inline result<parser> unpack(const parser &p, std::vector<uint8_t> &out) {
auto v = p.get_binary_view();
if (!v) return std::unexpected(v.error());