pub struct CityObject {
pub thetype: CityObjectType,
pub geographical_extent: Option<GeographicalExtent>,
pub attributes: Option<Value>,
pub geometry: Option<Vec<Geometry>>,
pub children: Option<Vec<String>>,
pub children_roles: Option<Vec<Option<String>>>,
pub parents: Option<Vec<String>>,
pub other: Value,
}Fields§
§thetype: CityObjectType§geographical_extent: Option<GeographicalExtent>§attributes: Option<Value>§geometry: Option<Vec<Geometry>>§children: Option<Vec<String>>§children_roles: Option<Vec<Option<String>>>§ 2.5 CityObjectGroup only: the role of each id in children, in the
same order. cityobjects.schema.json types each item as
["string", "null"], so an unspecified role is null, not simply
absent from the array.
parents: Option<Vec<String>>§other: ValueMembers the schema does not name, carried verbatim so they survive a
round trip. pub, like every other #[serde(flatten)] catch-all in
this crate, so a CityObject can be written as a struct literal.
Implementations§
Source§impl CityObject
impl CityObject
Sourcepub fn new(thetype: CityObjectType) -> Self
pub fn new(thetype: CityObjectType) -> Self
A City Object of thetype carrying nothing else.
other is deliberately not a constructor parameter: it is the
#[serde(flatten)] catch-all for members the schema does not name, and
a value built in code has none. Callers that need one set the named
fields directly, which are all pub.
This is a convenience, not a necessity: every field is pub, so a
struct literal works too. It saves writing seven Nones and getting
the other sentinel right (see below).
other is an empty object, not Value::Null: that is what
deserializing a City Object with no unrecognized members produces, and
the derived PartialEq compares it. A Null here would serialize
identically but make every constructed object compare unequal to its
parsed twin – silently, and only ever noticed by a test that compares
whole objects.
pub fn get_type(&self) -> CityObjectType
Trait Implementations§
Source§impl Clone for CityObject
impl Clone for CityObject
Source§fn clone(&self) -> CityObject
fn clone(&self) -> CityObject
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more