Zero-copy decode: span-based Envelope and DecodedMessage, defer usb_rx_buf clear

This commit is contained in:
Ian Gulliver
2026-04-10 23:08:51 +09:00
parent 76c519c17a
commit 7264611f99
3 changed files with 12 additions and 7 deletions

View File

@@ -773,6 +773,13 @@ inline result<parser> unpack(const parser &p, std::vector<uint8_t> &out) {
return p.next();
}
inline result<parser> unpack(const parser &p, std::span<const uint8_t> &out) {
auto v = p.get_binary_view();
if (!v) return std::unexpected(v.error());
out = std::span<const uint8_t>(reinterpret_cast<const uint8_t*>(v->data()), v->size());
return p.next();
}
template <typename T>
requires (!std::is_same_v<T, uint8_t>)
result<parser> unpack(const parser &p, std::vector<T> &out) {