Skip to content

Commit e2f92de

Browse files
authored
refactor: bring back stac-validate (#765)
Closes #748
1 parent ccc4007 commit e2f92de

40 files changed

+171
-139
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ members = [
1010
"crates/io",
1111
"crates/pgstac",
1212
"crates/server",
13+
"crates/validate",
1314
"crates/wasm",
1415
]
1516
default-members = [
1617
"crates/api",
1718
"crates/core",
18-
"crates/io",
1919
"crates/derive",
2020
"crates/extensions",
21+
"crates/io",
2122
"crates/server",
23+
"crates/validate",
2224
]
2325

2426
[workspace.package]
@@ -85,6 +87,7 @@ stac-duckdb = { version = "0.1.1", path = "crates/duckdb" }
8587
stac-extensions = { version = "0.1.0", path = "crates/extensions" }
8688
stac-io = { version = "0.1.0", path = "crates/io" }
8789
stac-server = { version = "0.3.2", path = "crates/server" }
90+
stac-validate = { version = "0.4.0", path = "crates/validate" }
8891
syn = "2.0"
8992
tempfile = "3.16"
9093
thiserror = "2.0"

crates/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ stac-duckdb.workspace = true
3030
stac-io = { workspace = true, features = [
3131
"store-all",
3232
"reqwest",
33-
"validate",
3433
"geoparquet-compression",
3534
] }
3635
stac-server = { workspace = true, features = ["axum", "duckdb"] }
36+
stac-validate.workspace = true
3737
tokio = { workspace = true, features = [
3838
"macros",
3939
"io-std",

crates/cli/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ use futures_core::TryStream;
99
use futures_util::{TryStreamExt, pin_mut};
1010
use stac::{Assets, Collection, Item, Links, Migrate, SelfHref, geoparquet::Compression};
1111
use stac_api::{GetItems, GetSearch, Search};
12-
use stac_io::{Format, StacStore, Validate};
12+
use stac_io::{Format, StacStore};
1313
use stac_server::Backend;
14+
use stac_validate::Validate;
1415
use std::{
1516
collections::{HashMap, VecDeque},
1617
io::Write,
@@ -492,7 +493,7 @@ impl Rustac {
492493
.spawn_blocking(move || value.validate())
493494
.await?;
494495
if let Err(error) = result {
495-
if let stac_io::Error::Validation(errors) = error {
496+
if let stac_validate::Error::Validation(errors) = error {
496497
if let Some(format) = self.output_format {
497498
if let Format::Json(_) = format {
498499
let value = errors

crates/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ url = { workspace = true, features = ["serde"] }
5555
assert-json-diff.workspace = true
5656
bytes.workspace = true
5757
rstest.workspace = true
58+
stac-validate.workspace = true
5859
tokio = { workspace = true, features = ["macros"] }
5960
tokio-test.workspace = true
6061

crates/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ pub fn version() -> &'static str {
290290
#[cfg(test)]
291291
mod tests {
292292
use rstest as _;
293+
use stac_validate as _;
293294
use tokio as _;
294295
use tokio_test as _;
295296

crates/io/tests/examples.rs renamed to crates/core/tests/examples.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rstest::rstest;
22
use stac::Value;
3-
use stac_io::Validate;
3+
use stac_validate::Validate;
44
use std::path::PathBuf;
55

66
#[rstest]

crates/io/tests/migrate.rs renamed to crates/core/tests/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rstest::rstest;
22
use stac::{Migrate, Value, Version};
3-
use stac_io::Validate;
3+
use stac_validate::Validate;
44
use std::path::PathBuf;
55

66
#[rstest]

crates/duckdb/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ thiserror.workspace = true
3333
[dev-dependencies]
3434
geo.workspace = true
3535
rstest.workspace = true
36-
stac-io = { workspace = true, features = ["validate"] }
36+
stac-validate.workspace = true

crates/duckdb/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ impl Client {
316316
if let Some(filter) = search.items.filter {
317317
let expr: Expr = filter.try_into()?;
318318
if expr_properties_match(&expr, &column_names) {
319-
let sql = expr.to_ducksql()?;
319+
let sql = expr.to_ducksql().map_err(Box::new)?;
320320
wheres.push(sql);
321321
} else {
322322
return Ok(Vec::new());
@@ -425,7 +425,7 @@ mod tests {
425425
use rstest::{fixture, rstest};
426426
use stac::Bbox;
427427
use stac_api::{Search, Sortby};
428-
use stac_io::Validate;
428+
use stac_validate::Validate;
429429

430430
#[fixture]
431431
#[once]

crates/duckdb/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub enum Error {
1010

1111
/// [cql2::Error]
1212
#[error(transparent)]
13-
Cql2(#[from] cql2::Error),
13+
Cql2(#[from] Box<cql2::Error>),
1414

1515
/// [duckdb::Error]
1616
#[error(transparent)]

0 commit comments

Comments
 (0)