Trait stac_server::Backend
source · pub trait Backend:
Clone
+ Sync
+ Send
+ 'static {
// Required methods
fn has_item_search(&self) -> bool;
fn collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Collection>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn collection<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Collection>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn add_collection<'life0, 'async_trait>(
&'life0 mut self,
collection: Collection,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn add_item<'life0, 'async_trait>(
&'life0 mut self,
item: Item,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn items<'life0, 'life1, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
items: Items,
) -> Pin<Box<dyn Future<Output = Result<Option<ItemCollection>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn item<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
item_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Item>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn search<'life0, 'async_trait>(
&'life0 self,
search: Search,
) -> Pin<Box<dyn Future<Output = Result<ItemCollection>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn add_from_hrefs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
hrefs: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
Storage backend for a STAC API.
Required Methods§
sourcefn has_item_search(&self) -> bool
fn has_item_search(&self) -> bool
Returns true if this backend has item search capabilities.
§Examples
use stac_server::{MemoryBackend, Backend};
assert_eq!(MemoryBackend::new().has_item_search(), cfg!(feature = "memory-item-search"));
sourcefn collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Collection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn collections<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Collection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns all collections.
§Examples
use stac_server::{MemoryBackend, Backend};
let backend = MemoryBackend::new();
let collections = backend.collections().await.unwrap();
assert!(collections.is_empty());
sourcefn collection<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Collection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn collection<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Collection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns a single collection.
§Examples
use stac_server::{MemoryBackend, Backend};
let backend = MemoryBackend::new();
let collection = backend.collection("does-not-exist").await.unwrap();
assert!(collection.is_none());
sourcefn add_collection<'life0, 'async_trait>(
&'life0 mut self,
collection: Collection,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_collection<'life0, 'async_trait>(
&'life0 mut self,
collection: Collection,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Adds a collection.
§Examples
use stac::Collection;
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
backend.add_collection(Collection::new("an-id", "a description")).await.unwrap();
sourcefn add_item<'life0, 'async_trait>(
&'life0 mut self,
item: Item,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_item<'life0, 'async_trait>(
&'life0 mut self,
item: Item,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Adds an item.
If the item doesn’t have its collection
field set, or a collection
with that id does not exist in the backend, throws an error.
§Examples
use stac::{Collection, Item};
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
assert!(backend.add_item(Item::new("item-id")).await.is_err());
backend.add_collection(Collection::new("collection-id", "a description")).await.unwrap();
backend.add_item(Item::new("item-id").collection("collection-id")).await.unwrap();
sourcefn items<'life0, 'life1, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
items: Items,
) -> Pin<Box<dyn Future<Output = Result<Option<ItemCollection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn items<'life0, 'life1, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
items: Items,
) -> Pin<Box<dyn Future<Output = Result<Option<ItemCollection>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves items for a given collection.
§Examples
use stac::{Collection, Item};
use stac_api::Items;
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
backend.add_collection(Collection::new("collection-id", "a description")).await.unwrap();
backend.add_item(Item::new("item-id").collection("collection-id")).await.unwrap();
let items = backend.items("collection-id", Items::default()).await.unwrap();
sourcefn item<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
item_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Item>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn item<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
collection_id: &'life1 str,
item_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Item>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Retrieves an item from a collection.
§Examples
use stac::{Collection, Item};
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
backend.add_collection(Collection::new("collection-id", "a description")).await.unwrap();
backend.add_item(Item::new("item-id").collection("collection-id")).await.unwrap();
let item = backend.item("collection-id", "item-id").await.unwrap().unwrap();
sourcefn search<'life0, 'async_trait>(
&'life0 self,
search: Search,
) -> Pin<Box<dyn Future<Output = Result<ItemCollection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search<'life0, 'async_trait>(
&'life0 self,
search: Search,
) -> Pin<Box<dyn Future<Output = Result<ItemCollection>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Searches a backend.
§Examples
use stac_api::Search;
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
let item_collection = backend.search(Search::default()).await.unwrap();
Provided Methods§
sourcefn add_from_hrefs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
hrefs: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_from_hrefs<'life0, 'life1, 'async_trait>(
&'life0 mut self,
hrefs: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Adds collections and items from hrefs.
A default implementation is provided.
§Examples
use stac_server::{MemoryBackend, Backend};
let mut backend = MemoryBackend::new();
backend.add_from_hrefs(&[
"tests/data/collection.json".to_string(),
"tests/data/feature.geojson".to_string(),
]);
Object Safety§
This trait is not object safe.