Expand description
§Crusty Traits Macros
This crate provides the crusty_trait procedural macro that transforms regular Rust traits
into FFI-safe traits with C-compatible vtables.
§Usage
Apply the #[crusty_trait] attribute to any trait to generate the necessary boilerplate
for FFI compatibility:
ⓘ
use crusty_traits::prelude::*;
#[crusty_trait]
pub trait MyTrait {
fn method(&self, value: i32) -> i32;
}The macro will generate:
- A C-compatible vtable struct (
MyTraitVTable) - Implementations for
CRepr<MyTraitVTable> - Memory management through
CDrop - Helper methods for creating and managing trait objects
Attribute Macros§
- crusty_
trait - The
crusty_traitprocedural macro transforms a Rust trait into an FFI-safe trait with a C-compatible vtable.