Add RequestInfo/ResponseInfo with MAC address
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user