Expand description
Rust interface for pgstac.
§Examples
Pgstac is a trait to query a pgstac database. It is implemented for anything that implements tokio_postgres::GenericClient:
use pgstac::Pgstac;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
println!("{}", client.pgstac_version().await.unwrap());
If you want to work in a transaction, you can do that too:
use pgstac::Pgstac;
use stac::Collection;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (mut client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
let transaction = client.transaction().await.unwrap();
transaction.add_collection(Collection::new("an-id", "a description")).await.unwrap();
transaction.commit().await.unwrap();
§Features
tls
: provide a function to create an unverified tls provider, which can be useful in some circumstances (see https://github.com/stac-utils/stac-rs/issues/375)
Structs§
- Page
- A page of search results.
Enums§
- Error
- Crate-specific error enum.
Traits§
- Pgstac
- Methods for working with pgstac.
Type Aliases§
- Json
Value - A serde_json::Value.
- Result
- Crate-specific result type.