unframe static method

List<List<int>> unframe(
  1. List<int> blob
)

Implementation

static List<List<int>> unframe(List<int> blob) {
  const op = 'DklsUtils.unframe';
  final out = <List<int>>[];
  var at = 0;
  while (at < blob.length) {
    if (at + 4 > blob.length) {
      throw CoreErrors.invalidOperationArguments(
        op,
        name: 'blob',
        reason: 'truncated frame header.',
      );
    }
    final len = _readU32(blob, at);
    at += 4;
    if (at + len > blob.length) {
      throw CoreErrors.invalidOperationArguments(
        op,
        name: 'blob',
        reason: 'truncated frame body.',
      );
    }
    out.add(blob.sublist(at, at + len));
    at += len;
  }
  return out;
}