cognite/dto/core/
common.rs1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5use serde_with::skip_serializing_none;
6
7#[derive(Serialize, Deserialize, Clone, Debug)]
8#[serde(rename_all = "camelCase")]
9pub enum CoreSortOrder {
11 Asc,
13 Desc,
15}
16
17#[derive(Serialize, Deserialize, Clone, Debug)]
18#[serde(rename_all = "camelCase")]
19pub enum CoreSortNulls {
21 First,
23 Last,
25 Auto,
27}
28
29#[skip_serializing_none]
30#[derive(Serialize, Deserialize, Debug, Default, Clone)]
31#[serde(rename_all = "camelCase")]
32pub struct CoreSortItem {
34 pub property: Vec<String>,
36 pub order: Option<CoreSortOrder>,
38 pub nulls: Option<CoreSortNulls>,
40}
41
42#[derive(Serialize, Deserialize, Debug, Clone)]
43#[serde(tag = "type")]
44pub enum GeoLocation {
46 Feature(Feature),
48}
49
50#[skip_serializing_none]
51#[derive(Serialize, Deserialize, Debug, Clone)]
52#[serde(rename_all = "camelCase")]
53pub struct Feature {
55 pub geometry: GeoLocationGeometry,
57 pub properties: Option<HashMap<String, Value>>,
59}
60pub type Point = [f64; 2];
62pub type LineString = Vec<Point>;
66pub type LinearRing = Vec<Point>;
70pub type Polygon = Vec<LinearRing>;
72#[derive(Serialize, Deserialize, Debug, Clone)]
73#[serde(tag = "type")]
74pub enum GeoLocationGeometry {
76 Point(GeometryItem<Point>),
78 LineString(GeometryItem<LineString>),
80 Polygon(GeometryItem<Polygon>),
82 MultiPoint(GeometryItem<Vec<Point>>),
84 MultiLineString(GeometryItem<Vec<LineString>>),
86 MultiPolygon(GeometryItem<Vec<Polygon>>),
88}
89
90#[derive(Serialize, Deserialize, Debug, Clone)]
91#[serde(rename_all = "camelCase")]
92pub struct GeometryItem<T> {
94 pub coordinates: T,
96}