Anki/proto/anki
Damien Elmes 553303fc12
Refactor service generation (#2552)
* Automatically elide empty inputs and outputs to backend methods

* Refactor service generation

Despite the fact that the majority of our Protobuf service methods require
an open collection, they were not accessible with just a Collection
object. To access the methods (e.g. because we haven't gotten around to
exposing the correct API in Collection yet), you had to wrap the collection
in a Backend object, and pay a mutex-acquisition cost for each call, even
if you have exclusive access to the object.

This commit migrates the majority of service methods to the Collection, so
they can now be used directly, and improves the ergonomics a bit at the
same time.

The approach taken:

- The service generation now happens in rslib instead of anki_proto, which
avoids the need for trait constraints and associated types.
- Service methods are assumed to be collection-based by default. Instead of
implementing the service on Backend, we now implement it on Collection, which
means our methods no longer need to use self.with_col(...).
- We automatically generate methods in Backend which use self.with_col() to
delegate to the Collection method.
- For methods that are only appropriate for the backend, we add a flag in
the .proto file. The codegen uses this flag to write the method into a
BackendFooService instead of FooService, which the backend implements.
- The flag can also allows us to define separate implementations for collection
and backend, so we can e.g. skip the collection mutex in the i18n service
while also providing the service on a collection.
2023-06-19 15:33:40 +10:00
..
ankidroid.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
backend.proto Move protobuf generation into a separate crate; write .py interface in Rust 2023-06-12 09:52:00 +10:00
card_rendering.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
cards.proto Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
codegen.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
collection.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
config.proto Remember previous choices in reposition dialog (#1950) 2022-07-08 11:28:38 +10:00
deckconfig.proto Add a fully-random review order 2023-04-11 16:16:45 +10:00
decks.proto Add non-legacy backend interface for adding new decks 2022-09-04 14:12:29 +10:00
generic.proto Add java_multiple_files option to proto files 2022-06-27 15:16:04 +10:00
i18n.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
image_occlusion.proto Migrate to protobuf-es (#2547) 2023-06-14 22:47:37 +10:00
import_export.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
links.proto Add java_multiple_files option to proto files 2022-06-27 15:16:04 +10:00
media.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
notes.proto Add java_multiple_files option to proto files 2022-06-27 15:16:04 +10:00
notetypes.proto Add ability to restore a notetype to its original configuration (#2472) 2023-04-18 14:07:51 +10:00
scheduler.proto Migrate to protobuf-es (#2547) 2023-06-14 22:47:37 +10:00
search.proto Allow burying cards in browser (#2351) 2023-01-30 19:21:06 +10:00
stats.proto fix stats calendar incorrect due to daylight savings time (#2456) 2023-03-28 15:35:06 +10:00
sync.proto Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
tags.proto Add java_multiple_files option to proto files 2022-06-27 15:16:04 +10:00