MySQLPacket.decodeColumnCountPacket constructor
MySQLPacket.decodeColumnCountPacket(
- Uint8List buffer
Decodifica um pacote que contém a contagem de colunas MySQLPacketColumnCount.
Implementation
factory MySQLPacket.decodeColumnCountPacket(Uint8List buffer) {
final header = decodePacketHeader(buffer);
final offset = 4;
final byteData = ByteData.sublistView(buffer);
final type = byteData.getUint8(offset);
late MySQLPacketPayload payload;
if (type == 0x00) {
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: header.item2,
payloadLength: header.item1,
payload: payload,
);
}