# A Stable Modular ABI for Rust

**URL:** <https://internals.rust-lang.org/t/a-stable-modular-abi-for-rust/12347>\
**Category:** compiler\
**Created:** [May 14, 2020, 6:14pm UTC](https://internals.rust-lang.org/t/a-stable-modular-abi-for-rust/12347 "2020-05-14T18:14:49Z")\
**Posts on this page:** 1\
**Showing post:** 37

<div class="post-metadata">

**Author:** ![ckaran](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@ckaran](https://internals.rust-lang.org/u/ckaran)\
**Post date:** [May 21, 2020, 6:03pm UTC](https://internals.rust-lang.org/t/a-stable-modular-abi-for-rust/12347/37 "2020-05-21T18:03:41Z")

</div>

Makes sense, but I have to admit I was kind of hoping it would work... you could then use rust to create glue between compiled objects that are in one ABI and get them to work with a different ABI. I fully admit that would be a niche application (only useful for code where you've lost the source, but still have the binary).

**EDIT**

I just realized that there could be another option. Would the following be expected to work?

```rust
#[repr(C)]
pub struct Blah_cabi {
    field_1: u8
}

impl From<Blah_rustabi> for Blah_cabi {
    // ...implementation details...
}

#[repr(Rust)]
pub struct Blah_rustabi {
    field_1: u8
}

impl From<Blah_cabi> for Blah_rustabi {
    // ...implementation details...
}

```

If so, it would be relatively easy to write up a derive macro that would generate the glue code, so you could have something like the following:

```rust
#[derive(ReprC, ReprRust)]
pub struct Blah {
    field_1: u8
}

```

---

_[View the full topic](https://internals.rust-lang.org/t/a-stable-modular-abi-for-rust/12347)._
