Remove SpaceId struct
This commit is contained in:
@@ -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<f64> = object.position().into();
|
||||
Some(SpaceSetObject::new(
|
||||
space.name(),
|
||||
|
||||
@@ -22,34 +22,6 @@ pub type ResultSet<'r> = Result<Vec<(&'r String, Vec<(Position, &'r Properties)>
|
||||
pub type ReferenceSpaceIndex = ironsea_index_hashmap::Index<Space, String>;
|
||||
type CoreIndex = ironsea_index_hashmap::Index<Core, String>;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
|
||||
pub struct SpaceId(String);
|
||||
|
||||
impl SpaceId {
|
||||
pub fn new<S>(space_name: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
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<S> From<S> for SpaceId
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
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<S>(&self, name: S) -> Result<SpaceId, String>
|
||||
pub fn space_id<S>(&self, name: S) -> Result<String, String>
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user