@staticmethod
def encode_stream(stream):
    """Utility method to encode a stream using utf-8.

        :param Any stream: The stream to be encoded using utf-8
        :return: A generator that yields the contents of the stream encoded as utf-8
        """
    for obj in stream:
        yield obj.encode('utf-8')
