{"id":13502908,"url":"https://github.com/1Password/typeshare","last_synced_at":"2025-03-29T12:33:16.387Z","repository":{"id":63604885,"uuid":"540976791","full_name":"1Password/typeshare","owner":"1Password","description":"Typeshare is the ultimate tool for synchronizing your type definitions between Rust and other languages for seamless FFI.","archived":false,"fork":false,"pushed_at":"2024-10-25T19:18:39.000Z","size":2015,"stargazers_count":2393,"open_issues_count":65,"forks_count":95,"subscribers_count":20,"default_branch":"main","last_synced_at":"2024-10-26T09:12:52.082Z","etag":null,"topics":["cli","ffi","rust","serde"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/1Password.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-24T21:50:44.000Z","updated_at":"2024-10-25T19:13:27.000Z","dependencies_parsed_at":"2023-02-09T12:46:29.004Z","dependency_job_id":"d9806bb2-b389-471e-8769-edee985232f7","html_url":"https://github.com/1Password/typeshare","commit_stats":{"total_commits":119,"total_committers":22,"mean_commits":5.409090909090909,"dds":0.4117647058823529,"last_synced_commit":"b00d2764d46499f81f71028ad8285e5b1fc10d00"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Ftypeshare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Ftypeshare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Ftypeshare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1Password%2Ftypeshare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1Password","download_url":"https://codeload.github.com/1Password/typeshare/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222495265,"owners_count":16993289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","ffi","rust","serde"],"created_at":"2024-07-31T22:02:29.728Z","updated_at":"2025-03-29T12:33:16.377Z","avatar_url":"https://github.com/1Password.png","language":"Rust","readme":"# Typeshare\n\n| Crate                | Status                                                                                                                                                                                                                                                                                                                                                                                                                                      |\n|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| typeshare            | [![crates.io version](https://img.shields.io/crates/v/typeshare.svg)](https://crates.io/crates/typeshare) [![crate documentation](https://docs.rs/typeshare/badge.svg)](https://docs.rs/typeshare) ![MSRV](https://img.shields.io/badge/rustc-stable-blue.svg) [![crates.io downloads](https://img.shields.io/crates/d/typeshare.svg)](https://crates.io/crates/typeshare)                                                                   |\n| typeshare-core       | [![crates.io version](https://img.shields.io/crates/v/typeshare-core.svg)](https://crates.io/crates/typeshare-core) [![crate documentation](https://docs.rs/typeshare-core/badge.svg)](https://docs.rs/typeshare-core) ![MSRV](https://img.shields.io/badge/rustc-stable-blue.svg) [![crates.io downloads](https://img.shields.io/crates/d/typeshare-core.svg)](https://crates.io/crates/typeshare-core)                                     |\n| typeshare-annotation | [![crates.io version](https://img.shields.io/crates/v/typeshare-annotation.svg)](https://crates.io/crates/typeshare-annotation) [![crate documentation](https://docs.rs/typeshare-annotation/badge.svg)](https://docs.rs/typeshare-annotation) ![MSRV](https://img.shields.io/badge/rustc-stable-blue.svg) [![crates.io downloads](https://img.shields.io/crates/d/typeshare-annotation.svg)](https://crates.io/crates/typeshare-annotation) |\n| typeshare-cli        | [![crates.io version](https://img.shields.io/crates/v/typeshare-cli.svg)](https://crates.io/crates/typeshare-cli) ![MSRV](https://img.shields.io/badge/rustc-stable-blue.svg) [![crates.io downloads](https://img.shields.io/crates/d/typeshare-cli.svg)](https://crates.io/crates/typeshare-cli)                                                                                                                                            |\n\n\n_One tool to rule the types,_\n\n_One tool to FFI them,_\n\n_One tool to parse your Rust,_\n\n_And in the darkness, compile them_ 💍\n\n\nDo 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\nRust types into their equivalent forms in Swift, Go**, Python**, Kotlin, Scala and Typescript, keeping\nyour 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!\n\n**A few caveats. See [here](#a-quick-refresher-on-supported-languages) for more details.\n\n## Installation\n\n\nTo install the CLI (Command Line Interface):\n```\ncargo install typeshare-cli\n```\n\n💡Note that the console command will be `typeshare`, not `typeshare-cli`.\n\nIn your `Cargo.toml`, under `[dependencies]`:\n\n```toml\ntypeshare = \"1.0.0\"\n```\n\n## Using Typeshare\nWe've put together a book that documents (almost) everything you can do.\n\n📚[Read the Typeshare book here!](https://1password.github.io/typeshare)\n\nTo 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:\n```\ntypeshare ./my_rust_project --lang=kotlin --output-file=my_kotlin_definitions.kt\ntypeshare ./my_rust_project --lang=swift --output-file=my_swift_definitions.swift\ntypeshare ./my_rust_project --lang=scala --output-file=my_scala_definitions.scala\ntypeshare ./my_rust_project --lang=typescript --output-file=my_typescript_definitions.ts\n```\n\n### Annotating Types\n\nInclude the `#[typeshare]` attribute with any struct or enum you define to generate definitions for that type in the selected output language.\n\n```rust\n// Rust type definitions\n\n#[typeshare]\nstruct MyStruct {\n    my_name: String,\n    my_age: u32,\n}\n\n#[typeshare]\n#[serde(tag = \"type\", content = \"content\")]\nenum MyEnum {\n    MyVariant(bool),\n    MyOtherVariant,\n    MyNumber(u32),\n}\n```\n```typescript\n// Generated Typescript definitions\n\nexport interface MyStruct {\n    my_name: string;\n    my_age: number;\n}\n\nexport type MyEnum =\n    | { type: \"MyVariant\", content: boolean }\n    | { type: \"MyOtherVariant\", content: undefined }\n    | { type: \"MyNumber\", content: number };\n```\n\n## Getting Help\n\nAre 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!\n\n## A Quick Refresher on Supported Languages\n\n- Kotlin\n- Scala\n- Swift\n- Typescript\n- Go**\n- Python** (see list of limitations [here](https://github.com/1Password/typeshare/issues/217))\n\n\nIf there is a language that you want Typeshare to generate definitions for, you can either:\n1. Open an issue in this repository requesting your language of choice.\n2. Implement support for that language and open a PR with your implementation. We would be eternally grateful! 🙏\n\n** 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.\n\n## Credits\n\nMade with ❤️ and ☕ by the [1Password](https://1password.com/) team.\n\n### Get a free 1Password account for your open source project\n\nDoes your team need a secure way to manage passwords and other credentials for your open source project? Head on over to our [other repository](https://github.com/1Password/1password-teams-open-source) to get a 1Password Teams account on us:\n\n✨[1Password for Open Source Projects](https://github.com/1Password/1password-teams-open-source)\n\n#### License\n\n\u003csup\u003e\nLicensed under either of \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version\n2.0\u003c/a\u003e or \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e at your option.\n\u003c/sup\u003e\n\n\u003cbr\u003e\n\n\u003csub\u003e\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this crate by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\u003c/sub\u003e\n","funding_links":[],"categories":["Rust","cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1Password%2Ftypeshare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1Password%2Ftypeshare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1Password%2Ftypeshare/lists"}