abi-singleton 0.1.0

Simple singleton trait
Documentation
# ABI SINGLETION


This is a simple ABI singleton Trait helper crate. When you need a trait that only one implementation can exist, you can use this crate.

## Usage


```rust
use abi_singleton::{api_impl, api_trait};

#[repr(C)]

pub struct Food {
    pub count: usize,
}

/// Trait definition:
#[allow(unused)]

#[api_trait]

trait Cat {
    unsafe fn eat(food: Food) -> usize;
}

/// Trait Implementation:
#[allow(unused)]

struct CatReal;

/// Function Implementation:
#[api_impl]

impl Cat for CatReal {
    unsafe fn eat(food: Food) -> usize {
        food.count
    }
}


// Use the trait:
// `[trait]Impl` is auto generated.
let count = unsafe { CatImpl::eat(Food { count: 3 }) };

```

## Limitations


Only C FFI func support, `self` fields are not supported.