parse static method

XLogDataMessage parse(
  1. Uint8List bytes,
  2. Encoding encoding
)

Parses the XLogDataMessage

If XLogDataMessage.data is a LogicalReplicationMessage, then the method will return a XLogDataLogicalMessage with that message. Otherwise, it'll return XLogDataMessage with raw data.

Implementation

static XLogDataMessage parse(Uint8List bytes, Encoding encoding) {
  final reader = PgByteDataReader(encoding: encoding)..add(bytes);
  final walStart = LSN(reader.readUint64());
  final walEnd = LSN(reader.readUint64());
  final time = dateTimeFromMicrosecondsSinceY2k(reader.readUint64());

  final message =
      tryParseLogicalReplicationMessage(reader, reader.remainingLength);
  if (message != null) {
    return XLogDataLogicalMessage(
      message: message,
      bytes: bytes,
      time: time,
      walEnd: walEnd,
      walStart: walStart,
    );
  } else {
    return XLogDataMessage(
      bytes: bytes,
      time: time,
      walEnd: walEnd,
      walStart: walStart,
    );
  }
}