Skip to content

Commit

Permalink
rename Shape to Value for Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr Martian committed Aug 1, 2024
1 parent 5893c79 commit 8213463
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "s2json"
version = "1.3.0"
version = "1.4.0"
edition = "2021"
authors = ["Craig O'Connor <[email protected]>"]
description = "This library supports the S2JSON 1.0 Specification"
Expand Down
1 change: 0 additions & 1 deletion cobertura.xml

This file was deleted.

2 changes: 0 additions & 2 deletions rust/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ where
seq.end()
}
}

impl<'de, T> Deserialize<'de> for BBox<T>
where
T: Deserialize<'de> + Copy,
Expand Down Expand Up @@ -122,7 +121,6 @@ where
seq.end()
}
}

impl<'de, T> Deserialize<'de> for BBox3D<T>
where
T: Deserialize<'de> + Copy,
Expand Down
22 changes: 11 additions & 11 deletions rust/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ pub enum ValueType {
/// An array of values
Array(Vec<ValuePrimitiveType>),
/// A nested object
Nested(Shape),
Nested(Value),
}

/// Shape design
pub type Shape = BTreeMap<String, ValueType>;
pub type Value = BTreeMap<String, ValueType>;
/// Shape of a features properties object
pub type Properties = Shape;
pub type Properties = Value;
/// Shape of a feature's M-Values object
pub type MValue = Shape;
pub type MValue = Value;

/// LineString Properties Shape
pub type LineStringMValues = Vec<MValue>;
Expand Down Expand Up @@ -168,17 +168,17 @@ mod tests {
}

#[test]
fn shape_serialize() {
let shape: Shape = BTreeMap::from([
fn value_serialize() {
let value: Value = BTreeMap::from([
("type".into(), ValueType::Primitive(PrimitiveValue::String("Point".into()))),
("coordinates".into(), ValueType::Primitive(PrimitiveValue::F32(1.0))),
]);
let serialized = serde_json::to_string(&shape).unwrap();
let serialized = serde_json::to_string(&value).unwrap();
assert_eq!(serialized, "{\"coordinates\":1.0,\"type\":\"Point\"}");
let deserialize = serde_json::from_str::<Shape>(&serialized).unwrap();
assert_eq!(deserialize, shape);
let deserialize = serde_json::from_str::<Value>(&serialized).unwrap();
assert_eq!(deserialize, value);

let shape_str = r#"
let value_str = r#"
{
"class": "ocean",
"offset": 22,
Expand All @@ -189,7 +189,7 @@ mod tests {
}
"#;

let deserialize = serde_json::from_str::<Shape>(shape_str).unwrap();
let deserialize = serde_json::from_str::<Value>(value_str).unwrap();
assert_eq!(deserialize, BTreeMap::from([
("class".into(), ValueType::Primitive(PrimitiveValue::String("ocean".into()))),
("offset".into(), ValueType::Primitive(PrimitiveValue::U64(22))),
Expand Down

0 comments on commit 8213463

Please sign in to comment.