Is there documentation regarding sending data between ts and python?

Recent changes in the DeckOptions uses bridge commands. I read in Improve presentation of importing results by abdnh · Pull Request #2568 · ankitects/anki · GitHub (linked to me by @brayanDso) that we should not use them anymore.
Except that new bridge commands were recently merged in anki in Fix 'Discard changes' dialog appearing even when no changes are made by hikaru-y · Pull Request #3495 · ankitects/anki · GitHub in the Deck Options.
I’d love correcting the deck options. It’s a very simple interface, with luck, if it’s done quickly, it would allow ankidroid to save time by directly using the correct implementation.
tried doing it in Testing removing bridge command · ankitects/anki@cd4a096 · GitHub , imitating other code, and utterly fail, I don’t know why.

Is there documentation anywhere about how to send post request from ts and receive them in python? I must admit that the following error message is not very clear.

milchior@Liamwayl:~/anki$ ./run
    Finished `release` profile [optimized] target(s) in 0.09s
failed: pylib:rsbridge
   Compiling anki v0.0.0 (/home/milchior/anki/rslib)
error: failed to run custom build command for `anki v0.0.0 (/home/milchior/anki/rslib)`

Caused by:
  process didn't exit successfully: `/home/milchior/anki/out/rust/debug/build/anki-e9adf8061d9be16b/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=../out/buildhash
  cargo:rustc-env=BUILDHASH=24fb21d8
  cargo:rerun-if-changed=/home/milchior/anki/out/rslib/proto/descriptors.bin

  --- stderr
  thread 'main' panicked at rslib/proto_gen/src/lib.rs:57:5:
  assertion `left == right` failed
    left: 23
   right: 22
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

More generally, I guess it’d be nice if we could have documentation explaining how all languages communicate with each other.

1 Like

If you move the stuff in deck_options.proto to FrontendService in frontend.proto, it should compile. This file is treated specially so it doesn’t require writing Rust implementations.

I’m not sure why you’re getting that particular error. I’m getting this helpful error instead, which helped me find a fix:

    Finished `release` profile [optimized] target(s) in 0.20s
failed: pylib:rsbridge
   Compiling anki_proto v0.0.0 (D:\dev\anki\repo\rslib\proto)
   Compiling anki v0.0.0 (D:\dev\anki\repo\rslib)
error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied      
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2050:44
     |
2050 |                 DeckOptions::require_close(self)?;
     |                 -------------------------- ^^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                 |
     |                 required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2054:54
     |
2054 |                 DeckOptions::confirm_discard_changes(self)?;
     |                 ------------------------------------ ^^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                 |
     |                 required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2058:49
     |
2058 |                 DeckOptions::deck_options_ready(self)?;
     |                 ------------------------------- ^^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                 |
     |                 required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:5541:56
     |
5541 |         self.with_col(|col| DeckOptions::require_close(col))
     |                             -------------------------- ^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                             |
     |                             required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:5544:66
     |
5544 |         self.with_col(|col| DeckOptions::confirm_discard_changes(col))
     |                             ------------------------------------ ^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                             |
     |                             required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

error[E0277]: the trait bound `collection::Collection: services::DeckOptions` is not satisfied
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:5547:61
     |
5547 |         self.with_col(|col| DeckOptions::deck_options_ready(col))
     |                             ------------------------------- ^^^ the trait `services::DeckOptions` is not implemented for `collection::Collection`
     |                             |
     |                             required by a bound introduced by this call
     |
help: this trait has no implementations, consider adding one
    --> D:\dev\anki\repo\tools\\..\out\rust\debug\build\anki-0340d9338417f7c3\out/backend.rs:2036:1
     |
2036 | pub trait DeckOptions {
     | ^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0277`.
error: could not compile `anki` (lib) due to 6 previous errors
Failed with code Some(101): cargo build --locked -p rsbridge --features native-tls

Build failed.
1 Like