serialize method

  1. @override
Uint8List serialize()
override

Serialize this instruction to bytes.

Implementation

@override
Uint8List serialize() {
  final indexBytes = QpackInteger.encode(nameIndex, 6);
  indexBytes[0] |= 0x80; // instruction prefix '1'
  if (isStatic) {
    indexBytes[0] |= 0x40; // T = 1
  }

  final valueBytes = QpackString.encode(value);
  final result = Uint8List(indexBytes.length + valueBytes.length);
  result.setRange(0, indexBytes.length, indexBytes);
  result.setRange(indexBytes.length, result.length, valueBytes);

  return result;
}