Complete refactor of the FFI to use handles instead of pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-06-24 14:44:23 +02:00
parent 4c222cb753
commit 78bb91093b
76 changed files with 1510 additions and 1952 deletions

View File

@@ -15,13 +15,17 @@ pub trait DataLibrary<T: ?Sized> {
fn get_modify(&mut self) -> &mut IndexMap<StringKey, Arc<T>>;
/// Adds a new value to the library.
fn add(&mut self, key: &StringKey, value: Arc<T>) {
self.get_modify().insert(key.clone(), value);
fn add(&self, key: &StringKey, value: Arc<T>) {
#[allow(clippy::unwrap_used)] // We know this cant fail.
let self_mut = unsafe { (self as *const Self as *mut Self).as_mut() }.unwrap();
self_mut.get_modify().insert(key.clone(), value);
}
/// Removes a value from the library.
fn remove(&mut self, key: &StringKey) {
self.get_modify().remove(key);
fn remove(&self, key: &StringKey) {
#[allow(clippy::unwrap_used)] // We know this cant fail.
let self_mut = unsafe { (self as *const Self as *mut Self).as_mut() }.unwrap();
self_mut.get_modify().remove(key);
}
/// Gets a value from the library.