ogcapi_drivers/
lib.rs

1#[cfg(feature = "postgres")]
2pub mod postgres;
3#[cfg(feature = "s3")]
4pub mod s3;
5
6#[cfg(feature = "common")]
7use ogcapi_types::common::{Collection, Collections, Query as CollectionQuery};
8#[cfg(feature = "edr")]
9use ogcapi_types::edr::{Query as EdrQuery, QueryType};
10#[cfg(feature = "processes")]
11use ogcapi_types::processes::{Results, StatusInfo};
12#[cfg(feature = "stac")]
13use ogcapi_types::stac::SearchParams;
14#[cfg(feature = "styles")]
15use ogcapi_types::styles::Styles;
16#[cfg(feature = "tiles")]
17use ogcapi_types::tiles::TileMatrixSet;
18#[cfg(feature = "features")]
19use ogcapi_types::{
20    common::Crs,
21    features::{Feature, Query as FeatureQuery},
22};
23
24#[cfg(any(feature = "features", feature = "stac", feature = "edr"))]
25use ogcapi_types::features::FeatureCollection;
26
27/// Trait for `Collection` transactions
28#[cfg(feature = "common")]
29#[async_trait::async_trait]
30pub trait CollectionTransactions: Send + Sync {
31    async fn create_collection(&self, collection: &Collection) -> anyhow::Result<String>;
32
33    async fn read_collection(&self, id: &str) -> anyhow::Result<Option<Collection>>;
34
35    async fn update_collection(&self, collection: &Collection) -> anyhow::Result<()>;
36
37    async fn delete_collection(&self, id: &str) -> anyhow::Result<()>;
38
39    async fn list_collections(&self, query: &CollectionQuery) -> anyhow::Result<Collections>;
40}
41
42/// Trait for `Feature` transactions
43#[cfg(feature = "features")]
44#[async_trait::async_trait]
45pub trait FeatureTransactions: Send + Sync {
46    async fn create_feature(&self, feature: &Feature) -> anyhow::Result<String>;
47
48    async fn read_feature(
49        &self,
50        collection: &str,
51        id: &str,
52        crs: &Crs,
53    ) -> anyhow::Result<Option<Feature>>;
54    async fn update_feature(&self, feature: &Feature) -> anyhow::Result<()>;
55
56    async fn delete_feature(&self, collection: &str, id: &str) -> anyhow::Result<()>;
57
58    async fn list_items(
59        &self,
60        collection: &str,
61        query: &FeatureQuery,
62    ) -> anyhow::Result<FeatureCollection>;
63}
64
65/// Trait for `STAC` search
66#[cfg(feature = "stac")]
67#[async_trait::async_trait]
68pub trait StacSeach: Send + Sync {
69    async fn search(&self, query: &SearchParams) -> anyhow::Result<FeatureCollection>;
70}
71
72/// Trait for `EDR` queries
73#[cfg(feature = "edr")]
74#[async_trait::async_trait]
75pub trait EdrQuerier: Send + Sync {
76    async fn query(
77        &self,
78        collection_id: &str,
79        query_type: &QueryType,
80        query: &EdrQuery,
81    ) -> anyhow::Result<FeatureCollection>;
82}
83
84/// Trait for `Processes` jobs
85#[cfg(feature = "processes")]
86#[async_trait::async_trait]
87pub trait JobHandler: Send + Sync {
88    async fn register(&self, job: &StatusInfo) -> anyhow::Result<String>;
89
90    async fn status(&self, id: &str) -> anyhow::Result<Option<StatusInfo>>;
91
92    async fn dismiss(&self, id: &str) -> anyhow::Result<Option<StatusInfo>>;
93
94    async fn results(&self, id: &str) -> anyhow::Result<Option<Results>>;
95}
96
97/// Trait for `Style` transactions
98#[cfg(feature = "styles")]
99#[async_trait::async_trait]
100pub trait StyleTransactions: Send + Sync {
101    async fn list_styles(&self) -> anyhow::Result<Styles>;
102
103    async fn read_style(&self, id: &str) -> anyhow::Result<Option<serde_json::Value>>;
104}
105
106/// Trait for `Tile` transacions
107#[cfg(feature = "tiles")]
108#[async_trait::async_trait]
109pub trait TileTransactions: Send + Sync {
110    async fn tile(
111        &self,
112        collections: &str,
113        tms: &TileMatrixSet,
114        matrix: &str,
115        row: u32,
116        col: u32,
117    ) -> anyhow::Result<Vec<u8>>;
118}