1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
use serde::{Deserialize, Serialize};
/// The core conformance uri.
pub const CORE_URI: &str = "https://api.stacspec.org/v1.0.0/core";
/// The features conformance uri.
pub const FEATURES_URI: &str = "https://api.stacspec.org/v1.0.0/ogcapi-features";
/// The collections conformance uri.
pub const COLLECTIONS_URI: &str = "https://api.stacspec.org/v1.0.0/collections";
/// The OGC API - Features - Part 1 Requirements Class Core uri
pub const OGC_API_FEATURES_URI: &str =
"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core";
/// The GeoJSON spec conformance uri.
pub const GEOJSON_URI: &str = "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson";
/// The item search conformance uri.
pub const ITEM_SEARCH_URI: &str = "https://api.stacspec.org/v1.0.0/item-search";
/// To support "generic" clients that want to access multiple OGC API Features
/// implementations - and not "just" a specific API / server, the server has to
/// declare the conformance classes it implements and conforms to.
#[derive(Debug, Serialize, Deserialize)]
pub struct Conformance {
/// The conformance classes it implements and conforms to.
#[serde(rename = "conformsTo")]
pub conforms_to: Vec<String>,
}
impl Conformance {
/// Creates a new conformance structure with only the core conformance class.
///
/// # Examples
///
/// ```
/// use stac_api::Conformance;
/// let conformance = Conformance::new();
/// ```
pub fn new() -> Conformance {
Conformance {
conforms_to: vec![CORE_URI.to_string()],
}
}
/// Adds
/// [ogcapi-features](https://github.com/radiantearth/stac-api-spec/tree/release/v1.0.0/ogcapi-features)
/// conformance classes.
///
/// # Examples
///
/// ```
/// use stac_api::Conformance;
/// let conformance = Conformance::new().ogcapi_features();
/// ```
pub fn ogcapi_features(mut self) -> Conformance {
self.conforms_to.push(FEATURES_URI.to_string());
self.conforms_to.push(COLLECTIONS_URI.to_string());
self.conforms_to.push(OGC_API_FEATURES_URI.to_string());
self.conforms_to.push(GEOJSON_URI.to_string());
self
}
/// Adds
/// [item search](https://github.com/radiantearth/stac-api-spec/tree/release/v1.0.0/item-search)
/// conformance class.
///
/// # Examples
///
/// ```
/// use stac_api::Conformance;
/// let conformance = Conformance::new().item_search();
/// ```
pub fn item_search(mut self) -> Conformance {
self.conforms_to.push(ITEM_SEARCH_URI.to_string());
self
}
}
impl Default for Conformance {
fn default() -> Self {
Self::new()
}
}