#cli #serde #command-line-tool #language

app typeshare-cli

Command Line Tool for generating language files with typeshare

8 releases (stable)

new 1.4.0 Mar 30, 2023
1.3.0 Mar 23, 2023
1.1.0-prerelease02 Feb 26, 2023
1.0.1 Dec 5, 2022
1.0.0 Nov 22, 2022

#179 in Command line utilities

Download history 29/week @ 2022-12-09 53/week @ 2022-12-16 13/week @ 2022-12-23 28/week @ 2022-12-30 65/week @ 2023-01-06 30/week @ 2023-01-13 162/week @ 2023-01-20 139/week @ 2023-01-27 158/week @ 2023-02-03 572/week @ 2023-02-10 3035/week @ 2023-02-17 2324/week @ 2023-02-24 2899/week @ 2023-03-03 2199/week @ 2023-03-10 3042/week @ 2023-03-17 2876/week @ 2023-03-24

11,637 downloads per month

MIT/Apache

325KB
9K SLoC

Rust 4K SLoC // 0.0% comments Swift 1.5K SLoC // 0.0% comments Go 1.5K SLoC // 0.0% comments Scala 692 SLoC // 0.1% comments Kotlin 669 SLoC // 0.1% comments TypeScript 285 SLoC // 0.1% comments

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

~7MB
~152K SLoC