randomPoison / cs-bindgen

Experiment in using Rust to build a library that can be loaded by Unity across multiple platforms
4 stars 0 forks source link

Don't require handle types to implement Describe #57

Closed randomPoison closed 4 years ago

randomPoison commented 4 years ago

The generated bindings don't need to introspect the contents of a type that's marshaled as a handle, since all such types are marshaled as an opaque pointer. Marshaling a type as a handle should allow for types that aren't directly FFI-safe or can't be fully described to be passed to C#, however we currently require that all types implement Describe. For example, if you have a foreign type that doesn't implement Describe or Abi in a struct that's marshaled by handled, that shouldn't prevent sending the struct to C# as long as the foreign type doesn't appear in the struct's exported interface anywhere.

Right now we're still deriving the Describe impl in the #[cs_bindgen] attribute. Moving this to its own proc-macro derive will give us better control over this situation as well, since more types can implement Describe without necessarily being exported with #[cs_bindgen].