MCPcopy Create free account
hub / github.com/attermann/microReticulum / msgpack_unwrap_bin

Function msgpack_unwrap_bin

examples/nomadnet/src/main.cpp:212–221  ·  view source on GitHub ↗

Decode a msgpack `bin` value into `out`. Returns true on success. The nomadnet response delivered to on_response by microReticulum is the msgpack-encoded `response` value from the server-side `umsgpack.packb([request_id, response])` envelope. nomadnet's serve_page returns Python `bytes`, which always serializes as msgpack `bin` — so unwrapping with bin_t is sufficient for the NomadNet us

Source from the content-addressed store, hash-verified

210// NomadNet use case. (Mirrors the same Unpacker pattern that
211// Link.cpp:1251-1255 uses to decode single-packet RESPONSE envelopes.)
212static bool msgpack_unwrap_bin(const RNS::Bytes& packed, RNS::Bytes& out) {
213 if (packed.size() < 1) return false;
214 MsgPack::Unpacker u;
215 u.feed(packed.data(), packed.size());
216 if (!u.isBin()) return false;
217 MsgPack::bin_t<uint8_t> bin;
218 u.deserialize(bin);
219 out = RNS::Bytes(bin.data(), bin.size());
220 return true;
221}
222
223// Write the raw response bytes (which we couldn't parse cleanly) to a
224// temp file. Returns the file path on success, empty string on failure.

Callers 1

on_responseFunction · 0.85

Calls 3

BytesClass · 0.85
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected