Determines element size after blob serialization.
        Can be quite tricky for complicated structures - another object required to implement sizeof()

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

async def get_element_size(self, elem_type, elem=None, params=None):
        """
        Determines element size after blob serialization.
        Can be quite tricky for complicated structures - another object required to implement sizeof()

        :param elem_type:
        :param elem:
        :param params:
        :return:
        """
        if hasattr(elem_type, 'blob_size'):
            elem = elem_type() if elem is None else elem
            return await elem.blob_size(self)

        if issubclass(elem_type, x.UVarintType):
            raise helpers.ArchiveException('Unknown size for varint')

        elif issubclass(elem_type, x.IntType):
            return elem_type.WIDTH

        elif issubclass(elem_type, x.BlobType):
            if elem is not None:
                return len(elem)
            if not elem_type.FIX_SIZE:
                raise helpers.ArchiveException('Unknown size for blob')
            return elem_type.SIZE

        elif issubclass(elem_type, x.UnicodeType):
            raise helpers.ArchiveException('Unknown size for string')

        elif issubclass(elem_type, x.VariantType):
            raise helpers.ArchiveException('Unknown size for variant')

        elif issubclass(elem_type, x.ContainerType):  # container ~ simple list
            celem_type = x.container_elem_type(elem_type, params)
            if elem is not None:
                return len(elem) * await self.get_element_size(elem_type=celem_type, elem=elem[0] if len(elem) > 0 else None)
            if not elem_type.FIX_SIZE:
                raise helpers.ArchiveException('Unknown size for container')
            return elem_type.SIZE * await self.get_element_size(elem_type=celem_type)

        elif issubclass(elem_type, x.TupleType):  # tuple ~ simple list
            acc = 0
            for t in elem_type.f_specs():
                acc += await self.get_element_size(t)
            return acc

        elif issubclass(elem_type, x.MessageType):
            acc = 0
            for t in elem_type.f_specs():
                acc += await self.get_element_size(t[1], params=t[2:])
            return acc

        else:
            raise TypeError