Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
        restrictions. Returns ``true`` upon success. If there is no space currently available:
            * If a timeout is provided, it waits until this timeout elapses and returns the result.
            * If a timeout is not provided, returns ``false`` immediately.

        :param item: (object), the item to be added.
        :param timeout: (long), maximum time in seconds to wait for addition (optional).
        :return: (bool), ``true`` if the element was added to this queue, ``false`` otherwise.

def offer(self, item, timeout=0):
        """
        Inserts the specified element into this queue if it is possible to do so immediately without violating capacity
        restrictions. Returns ``true`` upon success. If there is no space currently available:
            * If a timeout is provided, it waits until this timeout elapses and returns the result.
            * If a timeout is not provided, returns ``false`` immediately.

        :param item: (object), the item to be added.
        :param timeout: (long), maximum time in seconds to wait for addition (optional).
        :return: (bool), ``true`` if the element was added to this queue, ``false`` otherwise.
        """
        check_not_none(item, "Value can't be None")
        element_data = self._to_data(item)
        return self._encode_invoke(queue_offer_codec, value=element_data, timeout_millis=to_millis(timeout))