Dumps generic field to the popo object representation, according to the element specification.
    General multiplexer.

    :param obj:
    :param elem:
    :param elem_type:
    :param params:
    :return:

async def dump_field(obj, elem, elem_type, params=None):
    """
    Dumps generic field to the popo object representation, according to the element specification.
    General multiplexer.

    :param obj:
    :param elem:
    :param elem_type:
    :param params:
    :return:
    """
    if isinstance(elem, (int, bool)) or issubclass(elem_type, x.UVarintType) or issubclass(elem_type, x.IntType):
        return set_elem(obj, elem)

    elif issubclass(elem_type, x.BlobType) or isinstance(obj, bytes) or isinstance(obj, bytearray):
        return set_elem(obj, await dump_blob(elem))

    elif issubclass(elem_type, x.UnicodeType) or isinstance(elem, str):
        return set_elem(obj, elem)

    elif issubclass(elem_type, x.VariantType):
        return set_elem(obj, await dump_variant(None, elem, elem_type, params))

    elif issubclass(elem_type, x.ContainerType):  # container ~ simple list
        return set_elem(obj, await dump_container(None, elem, elem_type, params))

    elif issubclass(elem_type, x.MessageType):
        return set_elem(obj, await dump_message(None, elem))

    else:
        raise TypeError