A Stable Modular ABI for Rust

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?

#[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:

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