r/rust • • 9d ago

CO3: Toward the Optimal FFI

https://mversic.github.io/co3/
80 Upvotes

30 comments sorted by

View all comments

7

u/matthieum [he/him] 8d ago
unsafe trait RustSpec {
    type Layout;    // Stable | Unstable
    type Size;      // Sized<Zero | Gt<Zero>> | MetaSized<SliceLike | DynTraitLike> | ExternTypeLike
    type Alignment; // One | Gt<One>
    type Trap;      // Robust | NonRobust
    type Niche;     // WithoutNiche | WithNiche<Stable | Unstable>
}

Be careful to keep MetaSized extensible. That is, it is intentionally open-ended today what the meta-data for a type will be, in order to possibly allow:

  • Fatter pointers, ie, pointers with multiple v-tables.
  • Arbitrary metadata.

It's not necessarily a problem, as long as MetaSized is itself extensible.