Skip to main content

InteropType

Trait InteropType 

Source
pub unsafe trait InteropType:
    Any
    + Send
    + Sync {
    const TYPE_NAME: &'static str;
}
Expand description

A Rust type with an explicitly declared cross-language representation.

Implementing this trait promises that values of Self have the ABI layout expected by the foreign code that uses Self::TYPE_NAME. Packet::from_interop hashes that stable name and stores the value behind a foreign-readable pointer.

§Safety

The implementation must guarantee that:

  • Self has the same size, alignment and field layout as the foreign type registered under TYPE_NAME (normally use #[repr(C)]);
  • foreign readers treat the pointer as immutable and do not retain it beyond the packet’s lifetime;
  • TYPE_NAME is stable and uniquely identifies that layout across all participating binaries.

Required Associated Constants§

Source

const TYPE_NAME: &'static str

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§