Skip to main content

stac_server/backend/
mod.rs

1#[cfg(feature = "duckdb")]
2mod duckdb;
3mod memory;
4#[cfg(feature = "pgstac")]
5mod pgstac;
6
7use crate::Error;
8#[cfg(feature = "duckdb")]
9pub use duckdb::DuckdbBackend;
10pub use memory::MemoryBackend;
11#[cfg(feature = "pgstac")]
12pub use pgstac::PgstacBackend;
13use stac::api::{CollectionsClient, ItemsClient, StreamItemsClient, TransactionClient};
14
15/// Storage backend for a STAC API.
16///
17/// This trait combines [`ItemsClient`], [`CollectionsClient`],
18/// [`StreamItemsClient`], and [`TransactionClient`] with backend-specific
19/// capability flags.
20pub trait Backend:
21    ItemsClient<Error = Error>
22    + CollectionsClient<Error = Error>
23    + StreamItemsClient<Error = Error>
24    + TransactionClient<Error = Error>
25    + Clone
26    + Sync
27    + Send
28    + 'static
29{
30    /// Returns true if this backend has item search capabilities.
31    ///
32    /// # Examples
33    ///
34    /// ```
35    /// use stac_server::{MemoryBackend, Backend};
36    ///
37    /// assert!(MemoryBackend::new().has_item_search());
38    /// ```
39    fn has_item_search(&self) -> bool;
40
41    /// Returns true if this backend has [filter](https://github.com/stac-api-extensions/filter) capabilities.
42    ///
43    /// # Examples
44    ///
45    /// ```
46    /// use stac_server::{MemoryBackend, Backend};
47    ///
48    /// assert!(!MemoryBackend::new().has_filter());
49    /// ```
50    fn has_filter(&self) -> bool;
51}