unpackBinary method
Unpack value if packed value is binary or null
.
Encoded in msgpack packet null unpacks to List with 0 length for convenience. Throws FormatException if value is not a binary.
Implementation
List<int> unpackBinary() {
final b = _d.getUint8(_offset);
int len;
if (b == 0xc4) {
len = _d.getUint8(++_offset);
_offset += 1;
} else if (b == 0xc0) {
len = 0;
_offset += 1;
} else if (b == 0xc5) {
len = _d.getUint16(++_offset);
_offset += 2;
} else if (b == 0xc6) {
len = _d.getUint32(++_offset);
_offset += 4;
} else {
throw _formatException('Binary', b);
}
final data =
Uint8List.view(_list.buffer, _list.offsetInBytes + _offset, len);
_offset += len;
return data.toList();
}