first bits of a dynamc lib

This commit is contained in:
Dustin J. Mitchell
2022-01-22 22:48:40 +00:00
parent 8576e7ffa7
commit 33f5f056b1
13 changed files with 6942 additions and 1 deletions

1
lib/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
pub mod storage;

16
lib/src/storage.rs Normal file
View File

@@ -0,0 +1,16 @@
use taskchampion::{storage::Storage, StorageConfig};
pub struct StoragePtr(Box<dyn Storage>);
#[no_mangle]
pub extern "C" fn storage_new_in_memory() -> *mut StoragePtr {
// TODO: this is a box containing a fat pointer
Box::into_raw(Box::new(StoragePtr(
StorageConfig::InMemory.into_storage().unwrap(),
)))
}
#[no_mangle]
pub extern "C" fn storage_free(storage: *mut StoragePtr) {
drop(unsafe { Box::from_raw(storage) });
}