@@ -3,15 +3,14 @@ mod memory;
33mod pgstac;
44
55use crate :: Result ;
6- use async_trait:: async_trait;
76pub use memory:: MemoryBackend ;
87#[ cfg( feature = "pgstac" ) ]
98pub use pgstac:: PgstacBackend ;
109use stac:: { Collection , Item } ;
1110use stac_api:: { ItemCollection , Items , Search } ;
11+ use std:: future:: Future ;
1212
1313/// Storage backend for a STAC API.
14- #[ async_trait]
1514pub trait Backend : Clone + Sync + Send + ' static {
1615 /// Returns true if this backend has item search capabilities.
1716 ///
@@ -36,7 +35,7 @@ pub trait Backend: Clone + Sync + Send + 'static {
3635 /// assert!(collections.is_empty());
3736 /// # })
3837 /// ```
39- async fn collections ( & self ) -> Result < Vec < Collection > > ;
38+ fn collections ( & self ) -> impl Future < Output = Result < Vec < Collection > > > + Send ;
4039
4140 /// Returns a single collection.
4241 ///
@@ -50,7 +49,7 @@ pub trait Backend: Clone + Sync + Send + 'static {
5049 /// assert!(collection.is_none());
5150 /// # })
5251 /// ```
53- async fn collection ( & self , id : & str ) -> Result < Option < Collection > > ;
52+ fn collection ( & self , id : & str ) -> impl Future < Output = Result < Option < Collection > > > + Send ;
5453
5554 /// Adds a collection.
5655 ///
@@ -65,7 +64,8 @@ pub trait Backend: Clone + Sync + Send + 'static {
6564 /// backend.add_collection(Collection::new("an-id", "a description")).await.unwrap();
6665 /// # })
6766 /// ```
68- async fn add_collection ( & mut self , collection : Collection ) -> Result < ( ) > ;
67+ fn add_collection ( & mut self , collection : Collection )
68+ -> impl Future < Output = Result < ( ) > > + Send ;
6969
7070 /// Adds an item.
7171 ///
@@ -86,7 +86,7 @@ pub trait Backend: Clone + Sync + Send + 'static {
8686 /// backend.add_item(Item::new("item-id").collection("collection-id")).await.unwrap();
8787 /// # })
8888 /// ```
89- async fn add_item ( & mut self , item : Item ) -> Result < ( ) > ;
89+ fn add_item ( & mut self , item : Item ) -> impl Future < Output = Result < ( ) > > + Send ;
9090
9191 /// Retrieves items for a given collection.
9292 ///
@@ -104,7 +104,11 @@ pub trait Backend: Clone + Sync + Send + 'static {
104104 /// let items = backend.items("collection-id", Items::default()).await.unwrap();
105105 /// # })
106106 /// ```
107- async fn items ( & self , collection_id : & str , items : Items ) -> Result < Option < ItemCollection > > ;
107+ fn items (
108+ & self ,
109+ collection_id : & str ,
110+ items : Items ,
111+ ) -> impl Future < Output = Result < Option < ItemCollection > > > + Send ;
108112
109113 /// Retrieves an item from a collection.
110114 ///
@@ -121,7 +125,11 @@ pub trait Backend: Clone + Sync + Send + 'static {
121125 /// let item = backend.item("collection-id", "item-id").await.unwrap().unwrap();
122126 /// # })
123127 /// ```
124- async fn item ( & self , collection_id : & str , item_id : & str ) -> Result < Option < Item > > ;
128+ fn item (
129+ & self ,
130+ collection_id : & str ,
131+ item_id : & str ,
132+ ) -> impl Future < Output = Result < Option < Item > > > + Send ;
125133
126134 /// Searches a backend.
127135 ///
@@ -136,5 +144,5 @@ pub trait Backend: Clone + Sync + Send + 'static {
136144 /// let item_collection = backend.search(Search::default()).await.unwrap();
137145 /// # })
138146 /// ```
139- async fn search ( & self , search : Search ) -> Result < ItemCollection > ;
147+ fn search ( & self , search : Search ) -> impl Future < Output = Result < ItemCollection > > + Send ;
140148}
0 commit comments