1Password releases Typeshare, the "ultimate tool for synchronizing your type definitions between Rust and other languages for seamless FFI"

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/rust

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • SaaSHub - Software Alternatives and Reviews
  • diplomat

    Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code

  • typeshare

    Generate code in different languages from Rust type definitions for FFI interop.

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • bifrost

    At work we do something similar from GraphQL https://github.com/lookback/bifrost

  • crates.io

    The Rust package registry

    Thanks! Yeah, it's not on crates.io for a reason :D

  • uniffi-rs

    a multi-language bindings generator for rust

  • serde-reflection

    Rust libraries and tools to help with interoperability and testing of serialization formats based on Serde. (by zefchain)

  • rust

    Empowering everyone to build reliable and efficient software.

    rfc https://rust-lang.github.io/rfcs/2963-rustdoc-json.html and tracking issue https://github.com/rust-lang/rust/issues/

  • InfluxDB

    Build time-series-based applications quickly and at scale.. InfluxDB is the Time Series Platform where developers build real-time applications for analytics, IoT and cloud-native services. Easy to start, it is available in the cloud or on-premises.

  • Protobuf

    Protocol Buffers - Google's data interchange format

    Also, Google doesn't have official protobuf implementations for JS/TS, PHP, or Rust. The officially supported languages are listed here. The implementations you're describing may well be trash but that's not really a fair reflection of the quality of protobuf itself.

  • ssdcg

    Simple Service Description & Code Generator

    If you don’t mind writing definitions in a third language and making your own generator scripts, you could use my code generator: https://github.com/hardliner66/ssdcg

  • fbthrift

    Facebook's branch of Apache Thrift, including a new C++ server.

    Facebook had/has? Thrift as a more "proper" IDL.

  • moat

    mobile type (currently Swift, Kotlin) generation from Haskell types

    We do this at work, except with Haskell types: https://github.com/MercuryTechnologies/moat

  • marker

    An experimental linting interface for Rust. Let's make custom lints a reality (by rust-marker)

    Hey, I might be able to give some input how I deal with it in [rust-linting](https://github.com/rust-linting/rust-linting). For some context, the project needs to load several dynamic libraries and provide each of them with an abstract syntax tree. Serializing and deserializing the types for every step would most likely be too expensive. That's why I opted for a Rust <-> Rust FFI. There are two parts of this: 1. The loaded libraries needed to accept data from a driver. For this, I generate functions in the library crates which are marked as `extern "C"` and only use FFI safe types. Passing information to the loaded crates then always calls the generated functions, which intern call access a thread local struct instance in the dynamic crate. It's important that the instance implement a specific trait. For the library creation, it seems like magic. 2. Callbacks. The loaded libraries need to pass information back to the driver. For this, I use a struct with function pointers. These are also marked as `extern "C"` and need to only use FFI safe types. The definition of FFI safe, is a bit difficult. Slices, `str`, `Option<>` and most of the rusts STD types don't have a stable layout to the point, that it can change between compilations with the same compiler. Therefore, it's required that each passed type is `#[repr(C)]`. Options are wrapped in an enum, which has `#[repr(C)]`, slices and strings are dismantled into a data pointer and a length. On the receiving and they're reconstructed again. A small warning. I'm not an expert on FFI interfaces. My implementation would probably have some problems with lifetimes, if I'd use a slightly different memory model. So far, this has worked well (Besides the required boilerplate). The project is currently sadly lacking documentation, as it's still under heavy development. If you want, feel free to lock around the code base. The stable types and most of the interface is inside the `linter_api` crate.

  • wasm-bindgen

    Facilitating high-level interactions between Wasm modules and JavaScript

    This seems like it could be super useful for integrating with wasm-bindgen and TypeScript. Last I checked, the types generated by wasm-bindgen left a lot to be desired (no disrespect intended, wasm-bindgen is an awesome project). A few years ago, I contributed the skip_typescript attribute to wasm_bindgen that allowed you to override the type generation by hand-writing your own types (using a custom typescript section), but I wonder if this could simply generate higher quality types without the manual intervention.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts