11 stable releases
1.8.0 | Feb 28, 2024 |
---|---|
1.7.0 | Aug 11, 2023 |
1.6.0 | May 12, 2023 |
1.5.0 | Apr 13, 2023 |
1.0.0 | Nov 22, 2022 |
#774 in Command line utilities
1,091 downloads per month
365KB
10K
SLoC
typeshare
CLI built on top of typeshare-core
. Generate code in different languages from Rust type definitions for FFI interop.
Usage
cargo install typeshare
typeshare --lang=typescript some/file.rs
typeshare --lang=swift some/file.rs
typeshare --lang=kotlin --java-package=com.some.package.name some/file.rs
typeshare --lang=scala --scala-package=com.some.package.name some/file.rs
Generating FFI bindings
Include the typeshare annotation to generate a FFI binding for that function. Available languages are kotlin
and swift
.
#[typeshare(kotlin = "generateTotp", swift = "generate_totp")]
pub fn generate_totp(request: TotpGeneratorRequest) -> Result<TotpGeneratorResponse>`
Until the build system is changed to generate bindings during a build, it must be done manually and committed into the repo. FFI bindings are generated into the ffi/src/generated.rs
file.
To generate all FFI bindings run make ffi
. When adding or removing FFI bindings, don't forget to include the changes in the Makefile
.
Dependencies
~7–9.5MB
~167K SLoC