anki/rslib
Damien Elmes be994f4102 add support for custom undo steps, and merging multiple actions
Allows add-on authors to define their own label for a group of undoable
operations. For example:

def mark_and_bury(
    *,
    parent: QWidget,
    card_id: CardId,
) -> CollectionOp[OpChanges]:
    def op(col: Collection) -> OpChanges:
        target = col.add_custom_undo_entry("Mark and Bury")
        col.sched.bury_cards([card_id])
        card = col.get_card(card_id)
        col.tags.bulk_add(note_ids=[card.nid], tags="marked")
        return col.merge_undo_entries(target)

    return CollectionOp(parent, op)

The .add_custom_undo_entry() is for adding your own custom actions.
When extending a standard Anki action, instead store `target = 
col.undo_status().last_step` after executing the standard operation.

This started out as a bigger refactor that required a separate
.commit_undoable() call to be run after each operation, instead of
having each operation return changes directly. But that proved to be
somewhat cumbersome in unit tests, and ran the risk of unexpected
behaviour if the caller invoked an operation without remembering to
finalize it.
2021-05-06 16:39:06 +10:00
..
.cargo initial Bazel conversion 2020-11-01 14:26:58 +10:00
build tidy up Rust imports 2021-04-18 18:38:54 +10:00
cargo update Rust deps 2021-04-27 22:18:12 +10:00
i18n update Rust deps 2021-04-27 22:18:12 +10:00
src add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
templates migrate card stats to backend 2020-06-15 17:22:16 +10:00
tests/support initial Bazel conversion 2020-11-01 14:26:58 +10:00
.clang-format add .clang-format so VS Code preserves formatting style on .proto save 2021-01-12 18:47:08 +10:00
.gitignore initial Bazel conversion 2020-11-01 14:26:58 +10:00
backend.proto add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
BUILD.bazel update Rust deps 2021-04-27 22:18:12 +10:00
Cargo.toml report pinned package issues upstream 2021-04-27 23:11:22 +10:00
clang_format.bzl NF: add AGPL licence missing in some file 2021-01-31 21:50:21 +01:00
empty.rs add a valid, empty file so the check action works in Rust Analyzer 2021-05-05 15:53:27 +10:00
proto_format.py run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
README.md add some code editing/completion docs 2020-12-16 14:16:08 +10:00
rustfmt.bzl update to the latest rules_rust + security framework update 2021-03-27 19:28:19 +10:00
rustfmt.toml tidy up Rust imports 2021-04-18 18:38:54 +10:00

Anki's Rust code.

backend.proto stores the interfaces used to communicate backend messages between Rust, Python and TypeScript.