Read data from the ring buffer into a user-provided buffer.

        This advances the read index after reading;
        calling :meth:`advance_read_index` is *not* necessary.

        :param data: The memory where the data should be stored.
        :type data: CData pointer or buffer

        :returns: The number of elements read, which may be less than
            the size of *data*.
        :rtype: int

def readinto(self, data):
        """Read data from the ring buffer into a user-provided buffer.

        This advances the read index after reading;
        calling :meth:`advance_read_index` is *not* necessary.

        :param data: The memory where the data should be stored.
        :type data: CData pointer or buffer

        :returns: The number of elements read, which may be less than
            the size of *data*.
        :rtype: int

        """
        try:
            data = self._ffi.from_buffer(data)
        except TypeError:
            pass  # input is not a buffer
        size, rest = divmod(self._ffi.sizeof(data), self.elementsize)
        if rest:
            raise ValueError('data size must be multiple of elementsize')
        return self._lib.PaUtil_ReadRingBuffer(self._ptr, data, size)