FFI bindings helpers for Rust

This crate provides utilities for bindings to FFI interfaces

Features

Example usage

```

#[macrouse] extern crate easyffi_wrapper;

mod bindings {

use std::os::raw::c_char;

pub enum DataHandle {}
pub enum DataItem {}
extern {
    pub fn data_create() -> *mut DataHandle;
    pub fn data_release(_: *mut DataHandle);
    pub fn data_clone(_: *const DataHandle) -> *mut DataHandle;
    pub fn data_numbers(_: *const DataHandle, start: *mut *const u32, size: *mut usize);
    pub fn data_name(_: *const DataHandle, start: *mut *const c_char, size: *mut usize);
    pub fn data_item_len(_: *const DataHandle) -> usize;
    pub fn data_item_get(_: *const DataHandle, pos: usize) -> *const DataItem;
}

} use bindings::DataHandle as Data; use bindings::DataItem as DataItem; easyffiwrapper::ffibox!( Data, BoxedData, delete(bindings::datarelease), new(bindings::datacreate), clone(bindings::dataclone) ); easyffiwrapper::ffiiter!( ItemIter(Data) -> DataItem, len(bindings::dataitemlen), get(bindings::dataitemget) ); impl Data { pub fn name(&self) -> easyffiwrapper::Str { let mut value = easyffiwrapper::StrBuilder::new(); unsafe { bindings::dataname(self, &mut value.ptr, &mut value.len); value.build() } } pub fn numbers(&self) -> &[u32] { unsafe { let (mut ptr, mut len) = (std::ptr::null(), 0); bindings::datanumbers(self, &mut ptr, &mut len); easyffiwrapper::slicefromrawparts(ptr, len) } } pub fn items(&self) -> ItemIter { unsafe{ ItemIter::new(self) } } } ```