DecoderInstruction.parse constructor
DecoderInstruction.parse(
- Uint8List bytes
Parse a decoder instruction from bytes.
Reads the first byte to determine the instruction type, then decodes the remaining QPACK integer.
Implementation
factory DecoderInstruction.parse(Uint8List bytes) {
if (bytes.isEmpty) {
throw ArgumentError('Empty byte buffer');
}
final firstByte = bytes[0];
// Section Acknowledgment: T = 1, 7-bit prefix
if ((firstByte & 0x80) != 0) {
final (streamId, _) = QpackInteger.decode(bytes, 0, 7);
return SectionAcknowledgment(streamId: streamId);
}
// Stream Cancellation: T = 01, 6-bit prefix
if ((firstByte & 0x40) != 0) {
final (streamId, _) = QpackInteger.decode(bytes, 0, 6);
return StreamCancellation(streamId: streamId);
}
// Insert Count Increment: T = 00, 6-bit prefix
final (increment, _) = QpackInteger.decode(bytes, 0, 6);
return InsertCountIncrement(increment: increment);
}