Anki/rslib/src
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 Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
backend Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
card Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
card_rendering Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
collection Refactor progress handling (#2549) 2023-06-19 13:48:32 +10:00
config Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
deckconfig Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
decks Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
error Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
i18n Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
image_occlusion Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
import_export Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
media Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
notes Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
notetype Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
revlog Bump Rust version 2023-03-31 14:11:33 +10:00
scheduler Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
search Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
stats Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
storage Split io.rs into separate crate, and use it in proto build 2023-06-12 15:47:51 +10:00
sync Refactor progress handling (#2549) 2023-06-19 13:48:32 +10:00
tags Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
undo Fix invalid ids on db check (#2445) 2023-03-19 10:58:35 +10:00
adding.rs Default to current deck in csv import if settings allow it (#2527) 2023-05-31 13:47:12 +10:00
browser_table.rs Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
cloze.rs Feature image occlusion (#2367) 2023-03-29 12:33:19 +10:00
dbcheck.rs Refactor progress handling (#2549) 2023-06-19 13:48:32 +10:00
findreplace.rs Fix invalid ids on db check (#2445) 2023-03-19 10:58:35 +10:00
latex.rs Switch Rust import style (#2330) 2023-01-18 21:39:55 +10:00
lib.rs Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
links.rs Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
log.rs Update Rust deps (#2332) 2023-01-18 22:24:29 +10:00
markdown.rs Switch Rust import style (#2330) 2023-01-18 21:39:55 +10:00
ops.rs Feature image occlusion (#2367) 2023-03-29 12:33:19 +10:00
preferences.rs Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
prelude.rs Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
progress.rs Refactor progress handling (#2549) 2023-06-19 13:48:32 +10:00
serde.rs Automate schema 11 other duplicates clearing (#2542) 2023-06-12 11:14:14 +10:00
services.rs Refactor service generation (#2552) 2023-06-19 15:33:40 +10:00
template.rs Move generated protobuf into anki_proto 2023-06-12 15:47:51 +10:00
template_filters.rs Bump Rust version 2023-03-31 14:11:33 +10:00
tests.rs Add a .with_desktop_media_paths() helper 2023-05-18 11:02:02 +10:00
text.rs percent-encoding -> percent-encoding-iri 2023-05-29 14:46:02 +10:00
timestamp.rs Add time of date to browser date columns 2023-03-26 14:49:49 +10:00
typeanswer.rs Fix excess missed markers in non-Latin text 2023-02-10 15:11:36 +10:00
types.rs update scheduling ops 2021-04-06 16:38:42 +10:00
version.rs Rework syncing code, and replace local sync server (#2329) 2023-01-18 12:43:46 +10:00