async def dump_blob(elem, elem_type=None):
    """
    Dumps blob message.
    Supports both blob and raw value.

    :param writer:
    :param elem:
    :param elem_type:
    :param params:
    :return:
    """
    elem_is_blob = isinstance(elem, x.BlobType)
    data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
    if data is None or len(data) == 0:
        return b''
    if isinstance(data, (bytes, bytearray, list)):
        return base64.b16encode(bytes(data))
    else:
        raise ValueError('Unknown blob type')
async def dump_blob ( elem , elem_type = None ) : elem_is_blob = isinstance ( elem , x . BlobType ) data = getattr ( elem , x . BlobType . DATA_ATTR ) if elem_is_blob else elem if data is None or len ( data ) == 0 : return b'' if isinstance ( data , ( bytes , bytearray , list ) ) : return base64 . b16encode ( bytes ( data ) ) else : raise ValueError ( 'Unknown blob type' )
Dumps blob message.
    Supports both blob and raw value.

    :param writer:
    :param elem:
    :param elem_type:
    :param params:
    :return: