Synchronizes the given rules with the server
        and ensures that there are no old rules active
        which are not in the given list.

def sync(self, rules: list):
        """
        Synchronizes the given rules with the server
        and ensures that there are no old rules active
        which are not in the given list.
        """
        self._reset()
        old_rules = self.rules
        to_delete_rules = [
            rule for rule in old_rules
            if rule not in rules
        ]
        new_rules = [
            rule for rule in rules
            if rule not in old_rules
        ]

        for new_rule in new_rules:
            assert isinstance(new_rule, Rule)
            self._exec_command(new_rule.add_command)
        for to_delete_rule in to_delete_rules:
            assert isinstance(to_delete_rule, Rule)
            self._exec_command(
                to_delete_rule.remove_command
            )
        self._update(rules)