anki/rslib/Cargo.toml
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

115 lines
3.4 KiB
TOML

[package]
name = "anki"
publish = false
description = "Anki's Rust library code"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
[features]
bench = ["criterion"]
rustls = ["reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"]
native-tls = ["reqwest/native-tls"]
[[bench]]
name = "benchmark"
harness = false
required-features = ["bench"]
[build-dependencies]
anki_io = { version = "0.0.0", path = "io" }
anki_proto = { version = "0.0.0", path = "proto" }
anyhow = "1.0.71"
inflections = "1.1.1"
prettyplease = "0.2.7"
prost = "0.11.8"
prost-reflect = "0.11.4"
prost-types = "0.11.9"
syn = { version = "2.0.18", features = ["parsing", "printing"] }
[dev-dependencies]
async-stream = "0.3.4"
env_logger = "0.10.0"
wiremock = "0.5.17"
[dependencies.reqwest]
version = "0.11.16"
default-features = false
features = ["json", "socks", "stream", "multipart"]
[dependencies]
anki_i18n = { path = "i18n" }
anki_io = { path = "io" }
anki_proto = { path = "proto" }
workspace-hack = { version = "0.1", path = "../tools/workspace-hack" }
csv = { git = "https://github.com/ankitects/rust-csv.git", rev = "1c9d3aab6f79a7d815c69f925a46a4590c115f90" }
percent-encoding-iri = { git = "https://github.com/ankitects/rust-url.git", rev = "bb930b8d089f4d30d7d19c12e54e66191de47b88" }
# pinned as any changes could invalidate sqlite indexes
unicase = "=2.6.0"
criterion = { version = "0.4.0", optional = true }
ammonia = "3.3.0"
async-compression = { version = "0.3.15", features = ["zstd", "tokio"] }
async-trait = "0.1.68"
axum = { version = "0.6.12", features = ["multipart", "macros", "headers"] }
axum-client-ip = "0.3.1"
blake3 = "1.3.3"
bytes = "1.4.0"
chrono = { version = "0.4.26", default-features = false, features = ["std", "clock"] }
coarsetime = "0.1.23"
convert_case = "0.6.0"
difflib = "0.4.0"
flate2 = "1.0.25"
fluent = "0.16.0"
fluent-bundle = "0.15.2"
fnv = "1.0.7"
futures = "0.3.28"
hex = "0.4.3"
htmlescape = "0.3.1"
hyper = "0.14.25"
id_tree = "1.8.0"
itertools = "0.10.5"
lazy_static = "1.4.0"
nom = "7.1.3"
num_cpus = "1.15.0"
num_enum = "0.6.1"
once_cell = "1.17.1"
phf = "0.11.1"
pin-project = "1.0.12"
prost = "0.11.8"
pulldown-cmark = "0.9.2"
rand = "0.8.5"
regex = "1.7.3"
rusqlite = { version = "0.29.0", features = ["trace", "functions", "collation", "bundled"] }
scopeguard = "1.1.0"
serde = { version = "1.0.159", features = ["derive"] }
serde-aux = "4.1.2"
serde_json = "1.0.95"
serde_repr = "0.1.12"
serde_tuple = "0.5.0"
sha1 = "0.10.5"
snafu = { version = "0.7.4", features = ["backtraces", "rust_1_61"] }
strum = { version = "0.24.1", features = ["derive"] }
tempfile = "3.5.0"
tokio = { version = "1.27", features = ["fs", "rt-multi-thread", "macros", "signal"] }
tokio-util = { version = "0.7.7", features = ["io"] }
tower-http = { version = "0.4.0", features = ["trace"] }
tracing = { version = "0.1.37", features = ["max_level_trace", "release_max_level_debug"] }
tracing-appender = "0.2.2"
tracing-subscriber = { version = "0.3.16", features = ["fmt", "env-filter"] }
unic-ucd-category = "0.9.0"
unicode-normalization = "0.1.22"
utime = "0.3.1"
zip = { version = "0.6.4", default-features = false, features = ["deflate", "time"] }
zstd = { version = "0.12.3", features = ["zstdmt"] }
[target.'cfg(windows)'.dependencies.windows]
version = "0.48.0"
features = ["Media_SpeechSynthesis", "Foundation_Collections", "Storage_Streams"]