Typeshare is the ultimate tool for synchronizing your type definitions between Rust and other languages for seamless FFI.
Rust
2,989
547 commits
updated Oct 11, 2026
One tool to rule the types,
One tool to FFI them,
One tool to parse your Rust,
And in the darkness, compile them 💍
Do you like manually managing types that need to be passed through an FFI layer, so that your code doesn't archaically break at runtime? Be honest, nobody does. Typeshare is here to take that burden away from you! Leveraging the power of the serde library, Typeshare is a tool that converts your
Rust types into their equivalent forms in Swift, Go**, Python**, Kotlin, Scala and Typescript, keeping
your cross-language codebase in sync. With automatic implementation for serialization and deserialization on both sides of the FFI, Typeshare does all the heavy lifting for you. It can even handle generics and convert effortlessly between standard libraries in different languages!
**A few caveats. See here for more details.
To install the CLI (Command Line Interface):
cargo install typeshare-cli
💡Note that the console command will be typeshare, not typeshare-cli.
In your Cargo.toml, under [dependencies]:
typeshare = "1.0.0"
We've put together a book that documents (almost) everything you can do.
📚Read the Typeshare book here!
To generate FFI definitions for a target language, run the typeshare command and specify the directory containing your rust code, the language you would like to generate for, and the file to which your generated definitions will be written:
typeshare ./my_rust_project --lang=kotlin --output-file=my_kotlin_definitions.kt
typeshare ./my_rust_project --lang=swift --output-file=my_swift_definitions.swift
typeshare ./my_rust_project --lang=scala --output-file=my_scala_definitions.scala
typeshare ./my_rust_project --lang=typescript --output-file=my_typescript_definitions.ts
Include the #[typeshare] attribute with any struct or enum you define to generate definitions for that type in the selected output language.
// Rust type definitions
#[typeshare]
struct MyStruct {
my_name: String,
my_age: u32,
}
#[typeshare]
#[serde(tag = "type", content = "content")]
enum MyEnum {
MyVariant(bool),
MyOtherVariant,
MyNumber(u32),
}
// Generated Typescript definitions
export interface MyStruct {
my_name: string;
my_age: number;
}
export type MyEnum =
| { type: "MyVariant", content: boolean }
| { type: "MyOtherVariant", content: undefined }
| { type: "MyNumber", content: number };
Are you getting weird deserialization issues? Did our procedural macro throw a confusing error at you? Are you trying to contribute and our existing codebase is confusing? (probably true) Did you have another problem not enumerated in this reductive list? Please open an issue in this repository and the 1Password team would be happy to help! That's what we're here for!
If there is a language that you want Typeshare to generate definitions for, you can either:
** Right now, Go and Python support is experimental. Enable the go or python features, respectively, when installing typeshare-cli if you want to use these.
Made with ❤️ and ☕ by the 1Password team.
Does your team need a secure way to manage passwords and other credentials for your open source project? Head on over to our other repository to get a 1Password Teams account on us:
✨1Password for Open Source Projects
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 109)
535 followers · starred Aug 2025
68,756 followers · starred Nov 2022
1,519 followers · starred Nov 2022
456 followers · starred Nov 2022
Typeshare is the ultimate tool for synchronizing your type definitions between Rust and other languages for seamless FFI.
Rust
2,989
547 commits
updated Oct 11, 2026
One tool to rule the types,
One tool to FFI them,
One tool to parse your Rust,
And in the darkness, compile them 💍
Do you like manually managing types that need to be passed through an FFI layer, so that your code doesn't archaically break at runtime? Be honest, nobody does. Typeshare is here to take that burden away from you! Leveraging the power of the serde library, Typeshare is a tool that converts your
Rust types into their equivalent forms in Swift, Go**, Python**, Kotlin, Scala and Typescript, keeping
your cross-language codebase in sync. With automatic implementation for serialization and deserialization on both sides of the FFI, Typeshare does all the heavy lifting for you. It can even handle generics and convert effortlessly between standard libraries in different languages!
**A few caveats. See here for more details.
To install the CLI (Command Line Interface):
cargo install typeshare-cli
💡Note that the console command will be typeshare, not typeshare-cli.
In your Cargo.toml, under [dependencies]:
typeshare = "1.0.0"
We've put together a book that documents (almost) everything you can do.
📚Read the Typeshare book here!
To generate FFI definitions for a target language, run the typeshare command and specify the directory containing your rust code, the language you would like to generate for, and the file to which your generated definitions will be written:
typeshare ./my_rust_project --lang=kotlin --output-file=my_kotlin_definitions.kt
typeshare ./my_rust_project --lang=swift --output-file=my_swift_definitions.swift
typeshare ./my_rust_project --lang=scala --output-file=my_scala_definitions.scala
typeshare ./my_rust_project --lang=typescript --output-file=my_typescript_definitions.ts
Include the #[typeshare] attribute with any struct or enum you define to generate definitions for that type in the selected output language.
// Rust type definitions
#[typeshare]
struct MyStruct {
my_name: String,
my_age: u32,
}
#[typeshare]
#[serde(tag = "type", content = "content")]
enum MyEnum {
MyVariant(bool),
MyOtherVariant,
MyNumber(u32),
}
// Generated Typescript definitions
export interface MyStruct {
my_name: string;
my_age: number;
}
export type MyEnum =
| { type: "MyVariant", content: boolean }
| { type: "MyOtherVariant", content: undefined }
| { type: "MyNumber", content: number };
Are you getting weird deserialization issues? Did our procedural macro throw a confusing error at you? Are you trying to contribute and our existing codebase is confusing? (probably true) Did you have another problem not enumerated in this reductive list? Please open an issue in this repository and the 1Password team would be happy to help! That's what we're here for!
If there is a language that you want Typeshare to generate definitions for, you can either:
** Right now, Go and Python support is experimental. Enable the go or python features, respectively, when installing typeshare-cli if you want to use these.
Made with ❤️ and ☕ by the 1Password team.
Does your team need a secure way to manage passwords and other credentials for your open source project? Head on over to our other repository to get a 1Password Teams account on us:
✨1Password for Open Source Projects
Overall
Maintained
Code review
crates.io
Latest release
Releases this year
(top 24 of 109)
535 followers · starred Aug 2025
68,756 followers · starred Nov 2022
1,519 followers · starred Nov 2022
456 followers · starred Nov 2022