encode method

  1. @override
ByteBuffer encode(
  1. List<T> data
)
override

Implementation

@override
ByteBuffer encode(List<T> data) {
  final length = data.length;
  final bytes = ByteData(8 + length * tSizeInBytes);
  bytes.setInt64(0, length, Endian.big);
  for (int i = 0; i < data.length; i++) {
    final elementBytes = _tCodec.encode(data[i]).asByteData();
    assert(elementBytes.lengthInBytes == tSizeInBytes);
    for (int j = 0; j < tSizeInBytes; j++) {
      bytes.setUint8(8 + j + i * tSizeInBytes, elementBytes.getUint8(j));
    }
  }
  return bytes.buffer;
}