code: @Override
      public DecodingState decode(IoBuffer in, ProtocolDecoderOutput out)
              throws Exception {
          IoBufferEx inEx = (IoBufferEx) in;
          if (buffer == null) {
              if (in.remaining() >= length) {
                  int limit = in.limit();
                  in.limit(in.position() + length);
                  IoBufferEx product = inEx.slice();
                  in.position(in.position() + length);
                  in.limit(limit);
                  return finishDecode((IoBuffer) product, out);
              }
  
              buffer = allocator.wrap(allocator.allocate(length));
              buffer.put(inEx);
              return this;
          }
  
          if (in.remaining() >= length - buffer.position()) {
              int limit = in.limit();
              in.limit(in.position() + length - buffer.position());
              buffer.put(inEx);
              in.limit(limit);
              buffer.flip();
              IoBufferEx product = buffer;
              buffer = null;
              return finishDecode((IoBuffer) product, out);
          }
  
          buffer.put(inEx);
          return this;
      }
docs: {@inheritDoc}