Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Is there a way to get the signature of all the commands that can be invoked? #6354

Closed
leiserfg opened this issue Feb 24, 2023 · 2 comments

Comments

@leiserfg
Copy link

Describe the problem

I want to make a tool to auto-generate the javascript FFI for elm (what you have in @tauri/api but for elm), including custom Commands. Having a way to get those types would be also beneficial for doing the same for other languages (rescript, purescript) and even for typescript (so you don't have to keep the api up to date by hand).

Describe the solution you'd like

A tool to extract all the Commands (names and types) in an easy processable format (maybe jsonschema, protobuf declaration or similar) so they can be used for automatic clientside code generation.

Alternatives considered

  • Writing the ports (thats how elm calls javascript FFI) by hand is possible but tedious.
  • Parsing the API library and generating the Ports from that, the downside is not having the custom commands included.that's

Additional context

Maybe https://docs.rs/schemars/latest/schemars/ could bring some inspiration.

@leiserfg leiserfg changed the title [feat] Is there a way to get the signature of all the commands that can be invoked at comptime? [feat] Is there a way to get the signature of all the commands that can be invoked? Feb 24, 2023
@FabianLars
Copy link
Member

I'd count this as a duplicate of #1514. The title may not suggest that but the discussion broadened/generalized a bit and especially the tauri-bindgen and tauri-specta projects mentioned there go in the direction you're asking for.

There is also a potentially interesting discussion in #3256.

@FabianLars FabianLars closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@JonasKruckenberg
Copy link
Contributor

JonasKruckenberg commented Feb 24, 2023

With #3256 we can theoretically generate a signature type for each command (one that tracks parameters, returns and async-ness) but I don't see what benefit that would bring in the context of tauri-core (I had thought in the past that maybe we could inject generating javascript bindings straight from Rust, but that idea isn't too useful either bc of lacking typescript support) so I think projects like what fabian mentioned are more equipped to help here and this is not something tauri core should concern itself with.

Btw your problem description sounds exactly like what I started tauri-bindgen for. Feel free to create an issue over there and we can discuss adding codegen support for elm 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants