first bits of a dynamc lib
This commit is contained in:
1
lib/src/lib.rs
Normal file
1
lib/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod storage;
|
||||
16
lib/src/storage.rs
Normal file
16
lib/src/storage.rs
Normal 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) });
|
||||
}
|
||||
Reference in New Issue
Block a user