code: @Override
      public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)
              throws Exception {
          int beginPos = in.position();
          int terminatorPos = -1;
          int limit = in.limit();
  
          for (int i = beginPos; i < limit; i++) {
              byte b = in.get(i);
              if (isTerminator(b)) {
                  terminatorPos = i;
                  break;
              }
          }
  
          if (terminatorPos >= 0) {
              IoBufferEx product;
  
              if (beginPos < terminatorPos) {
                  in.limit(terminatorPos);
  
                  if (buffer == null) {
                      product = ((IoBufferEx) in).slice();
                  } else {
                      buffer.put((IoBufferEx) in);
                      product = buffer.flip();
                      buffer = null;
                  }
  
                  in.limit(limit);
              } else {
                  // When input contained only terminator rather than actual data...
                  if (buffer == null) {
                      product = allocator.wrap(allocator.allocate(0));
                  } else {
                      product = buffer.flip();
                      buffer = null;
                  }
              }
              in.position(terminatorPos + 1);
              return finishDecode(product.asIoBuffer(), out);
          }
  
          if (buffer == null) {
              buffer = allocator.wrap(allocator.allocate(in.remaining()));
              buffer.setAutoExpander(allocator);
          }
          buffer.put((IoBufferEx) in);
          return this;
      }
docs: {@inheritDoc}