crusty_traits_macros 0.1.0

Procedural macros for crusty_traits - FFI-safe trait generation
Documentation

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