diff --git a/crates/pgstac/src/lib.rs b/crates/pgstac/src/lib.rs index 6a74b4e3..0ce9a2e5 100644 --- a/crates/pgstac/src/lib.rs +++ b/crates/pgstac/src/lib.rs @@ -81,6 +81,7 @@ mod tls; pub use page::Page; use serde::{de::DeserializeOwned, Serialize}; +use stac_api::Search; use tokio_postgres::{types::ToSql, GenericClient, Row}; #[cfg(feature = "tls")] pub use {tls::make_unverified_tls, tokio_postgres_rustls::MakeRustlsConnect}; @@ -92,6 +93,10 @@ pub enum Error { #[error(transparent)] SerdeJson(#[from] serde_json::Error), + /// [stac_api::Error] + #[error(transparent)] + StacApi(#[from] stac_api::Error), + /// [tokio_postgres::Error] #[error(transparent)] TokioPostgres(#[from] tokio_postgres::Error), @@ -231,12 +236,9 @@ pub trait Pgstac: GenericClient { } /// Searches for items. - async fn search(&self, search: T) -> Result - where - T: Serialize, - { + async fn search(&self, search: Search) -> Result { + let search = search.into_cql2_json()?; let search = serde_json::to_value(search)?; - // TODO do we want to check for cql2-text? self.value("search", &[&search]).await }