code: public static ProtocolDetectionResult<HAProxyProtocolVersion> detectProtocol(ByteBuf buffer) {
          if (buffer.readableBytes() < 12) {
              return ProtocolDetectionResult.needsMoreData();
          }
  
          int idx = buffer.readerIndex();
  
          if (match(BINARY_PREFIX, buffer, idx)) {
              return DETECTION_RESULT_V2;
          }
          if (match(TEXT_PREFIX, buffer, idx)) {
              return DETECTION_RESULT_V1;
          }
          return ProtocolDetectionResult.invalid();
      }
docs: Returns the {@link ProtocolDetectionResult} for the given {@link ByteBuf}.