diff --git a/src/database/db_core.rs b/src/database/db_core.rs index c53c81f..4e16c3c 100644 --- a/src/database/db_core.rs +++ b/src/database/db_core.rs @@ -106,7 +106,7 @@ impl Core { let filtered = space_objects .iter() .filter_map(|object| { - if &object.space_id().0 == space.name() { + if object.space_id() == space.name() { let position: Vec = object.position().into(); Some(SpaceSetObject::new( space.name(), diff --git a/src/database/mod.rs b/src/database/mod.rs index 26125cc..459f40e 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -22,34 +22,6 @@ pub type ResultSet<'r> = Result pub type ReferenceSpaceIndex = ironsea_index_hashmap::Index; type CoreIndex = ironsea_index_hashmap::Index; -#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)] -pub struct SpaceId(String); - -impl SpaceId { - pub fn new(space_name: S) -> Self - where - S: Into, - { - SpaceId(space_name.into()) - } - - pub fn get(&self, index: &ReferenceSpaceIndex) -> Self { - let s = index.find(&self.0); - assert_eq!(s.len(), 1); - - SpaceId(s[0].name().clone()) - } -} - -impl From for SpaceId -where - S: Into, -{ - fn from(id: S) -> Self { - SpaceId(id.into()) - } -} - #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)] pub struct SpaceObject { pub space_id: String, @@ -162,7 +134,7 @@ impl DataBase { } } - pub fn space_id(&self, name: S) -> Result + pub fn space_id(&self, name: S) -> Result where S: Into, { @@ -170,7 +142,7 @@ impl DataBase { let r = self.reference_spaces.find(&name); let s: &Space = Self::check_exactly_one(&r, "spaces", &name)?; - Ok(SpaceId(s.name().clone())) + Ok(s.name().clone()) } // Lookup a space within the reference spaces registered diff --git a/src/database/space_index.rs b/src/database/space_index.rs index 983ac99..d9e85b1 100644 --- a/src/database/space_index.rs +++ b/src/database/space_index.rs @@ -5,11 +5,10 @@ use ironsea_index::IndexedDestructured; use super::space::Coordinate; use super::space::Position; use super::space::Shape; -use super::SpaceId; #[derive(Clone, Debug, Hash)] pub struct SpaceSetObject { - space_id: SpaceId, + space_id: String, position: Position, value: Coordinate, // Efficiently store the offset within the SpaceDB values vector } @@ -27,7 +26,7 @@ impl SpaceSetObject { &self.value } - pub fn space_id(&self) -> &SpaceId { + pub fn space_id(&self) -> &String { &self.space_id } @@ -50,23 +49,19 @@ impl SpaceSetObject { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SpaceFields { - space_id: SpaceId, + space_id: String, value: Coordinate, } impl SpaceFields { - pub fn new(space_id: SpaceId, value: Coordinate) -> Self { + pub fn new(space_id: String, value: Coordinate) -> Self { SpaceFields { space_id, value } } - /* - pub fn id(&self) -> &Coordinate { - &self.value - } - pub fn space_id(&self) -> &SpaceId { - &self.space_id - } - */ + pub fn space_id(&self) -> &String { + &self.space_id + } + pub fn value(&self) -> &Coordinate { &self.value }