Attribute Macro cglue_macro::vtbl_only

source ·
#[vtbl_only]
Expand description

Emit a vtable entry, but do not use it in Rust.

This allows to expose functionality to C/C++ users with slight changes in return types, while making use of the blanket implementation in Rust. It is necessary when a function itself wraps Self into some specific type, and would otherwise be completely incompatible with CGlue.

User is able to specify one of the wrapping macros to configure the behavior:

#[vtbl_only(wrap_with_obj(ExampleTrait))]

Note that there could be some parity issues between Rust and C/C++ APIs, because in Rust the blanket implementation will be invoked, while in FFI the underlying implementation will be called.