MySQLPacket.decodeColumnCountPacket constructor
MySQLPacket.decodeColumnCountPacket(
- Uint8List buffer
Implementation
factory MySQLPacket.decodeColumnCountPacket(Uint8List buffer) {
final byteData = ByteData.sublistView(buffer);
int offset = 0;
final header = MySQLPacket.decodePacketHeader(buffer);
offset += 4;
final payloadLength = header.item1;
final sequenceNumber = header.item2;
final type = byteData.getUint8(offset);
MySQLPacketPayload payload;
if (type == 0x00) {
// OK packet
payload = MySQLPacketOK.decode(Uint8List.sublistView(buffer, offset));
} else if (type == 0xff) {
payload = MySQLPacketError.decode(Uint8List.sublistView(buffer, offset));
} else if (type == 0xfb) {
throw MySQLProtocolException(
"COM_QUERY_RESPONSE of type 0xfb is not implemented",
);
} else {
payload =
MySQLPacketColumnCount.decode(Uint8List.sublistView(buffer, offset));
}
return MySQLPacket(
sequenceID: sequenceNumber,
payloadLength: payloadLength,
payload: payload,
);
}