From 881ae8c0966d3ff2c707186120ead2fa7d19e765 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 12 Dec 2023 11:03:24 +0100 Subject: [PATCH] renamed trait --- mission_rust/src/fsrc/datasets/mod.rs | 20 ++++++++++---------- mission_rust/src/lib.rs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mission_rust/src/fsrc/datasets/mod.rs b/mission_rust/src/fsrc/datasets/mod.rs index a2304be..bc04710 100644 --- a/mission_rust/src/fsrc/datasets/mod.rs +++ b/mission_rust/src/fsrc/datasets/mod.rs @@ -7,11 +7,11 @@ pub struct TypeId { } // inspired by https://github.com/jswrenn/deflect/ -pub trait Reflection { +pub trait HasTypeId { #[inline(never)] fn get_type_id(&self) -> TypeId { TypeId { - id: ::get_type_id as usize, + id: Self::get_type_id as usize, } } } @@ -24,27 +24,27 @@ pub trait DatapoolOwnerIF { pub trait DataSetIF { fn get_type_id(&self) -> TypeId; - fn get_actual_data(&self) -> &dyn Reflection; + fn get_actual_data(&self) -> &dyn HasTypeId; fn get_mutex(&self) -> mutex::RawMutex; } -pub struct OwnedDataset { +pub struct OwnedDataset { actual_data: T, mutex: mutex::RawMutex, } -pub struct ReferencedDataset { +pub struct ReferencedDataset { //we use a pointer here to avoid lifetimes actual_data: Option<*const T>, mutex: Option, } -impl DataSetIF for OwnedDataset { +impl DataSetIF for OwnedDataset { fn get_type_id(&self) -> TypeId { self.actual_data.get_type_id() } - fn get_actual_data(&self) -> &dyn Reflection { + fn get_actual_data(&self) -> &dyn HasTypeId { &self.actual_data } @@ -53,7 +53,7 @@ impl DataSetIF for OwnedDataset { } } -impl OwnedDataset { +impl OwnedDataset { pub fn new() -> OwnedDataset { OwnedDataset:: { actual_data: T::default(), @@ -79,7 +79,7 @@ impl OwnedDataset { } } -impl ReferencedDataset { +impl ReferencedDataset { pub fn new() -> ReferencedDataset { ReferencedDataset:: { actual_data: None, @@ -115,7 +115,7 @@ impl ReferencedDataset { } //pointer cast is safe because we checked the type_id //getting pointer to avoid lifetime check - self.actual_data = Some(other_set.get_actual_data() as *const dyn Reflection as *const T); + self.actual_data = Some(other_set.get_actual_data() as *const dyn HasTypeId as *const T); self.mutex = Some(other_set.get_mutex()); Ok(()) } diff --git a/mission_rust/src/lib.rs b/mission_rust/src/lib.rs index 4a56dbd..fa07f9b 100644 --- a/mission_rust/src/lib.rs +++ b/mission_rust/src/lib.rs @@ -56,7 +56,7 @@ struct HandlerData { y: f32 } -impl datasets::Reflection for HandlerData {} +impl datasets::HasTypeId for HandlerData {} struct Handler { id: objectmanager::ObjectId,