crusty_traits_core/
lib.rs

1//! # Crusty Traits Core
2//!
3//! This module provides core traits and types for creating C-compatible vtables for Rust traits.
4//! It includes the fundamental building blocks: `CRef`, `CRefMut`, `CRepr`, `CDrop`, and `AsVTable`.
5//!
6//! ## Core Types
7//!
8//! - [`CRef`] - A C-compatible reference to a trait object
9//! - [`CRefMut`] - A C-compatible mutable reference to a trait object  
10//! - [`CRepr`] - A C-compatible representation of a trait object with its vtable
11//! - [`CDrop`] - A trait for dropping objects in a C-compatible way
12//! - [`AsVTable`] - A trait for converting types to vtables
13//!
14//! These types work together to enable safe FFI interactions with Rust trait objects.
15
16mod trait_wrapper;
17
18pub use trait_wrapper::*;
19
20/// A trait that represents dropping a Rust object in a C-compatible way.
21pub trait CDrop {
22    /// Drops the object represented by the given `CRepr`.
23    fn drop(repr: CRefMut<Self>);
24}
25
26/// A trait that provides a way to convert a type into a C-compatible vtable.
27pub trait AsVTable<T: ?Sized> {
28    /// Return a vtable for the type.
29    fn as_vtable(&self) -> T;
30}