docs: void getBytesToSendToPeer(ByteBuf out) throws GeneralSecurityException {
      checkState(unwrapper != null, "protector already created");
      try (BufUnwrapper unwrapper = this.unwrapper) {
        // Write as many bytes as possible into the buffer.
        int bytesWritten = 0;
        for (ByteBuffer nioBuffer : unwrapper.writableNioBuffers(out)) {
          if (!nioBuffer.hasRemaining()) {
            // This buffer doesn't have any more space to write, go to the next buffer.
            continue;
          }
  
          int prevPos = nioBuffer.position();
          internalHandshaker.getBytesToSendToPeer(nioBuffer);
          bytesWritten += nioBuffer.position() - prevPos;
  
          // If the buffer position was not changed, the frame has been completely read into the
          // buffers.
          if (nioBuffer.position() == prevPos) {
            break;
          }
        }
  
        out.writerIndex(out.writerIndex() + bytesWritten);
      }
    }