pub struct Client<'a, C>(/* private fields */)
where
C: GenericClient;
Expand description
A pgstac client.
Not every pgstac function is provided, and some names are changed to match Rust conventions.
We don’t own the inner client because we want to be able to work with references, e.g. those returned by bb8_postgres.
Implementations§
source§impl<'a, C: GenericClient> Client<'a, C>
impl<'a, C: GenericClient> Client<'a, C>
sourcepub fn new(client: &C) -> Client<'_, C>
pub fn new(client: &C) -> Client<'_, C>
Creates a new client.
§Examples
use pgstac::Client;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (mut client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
let client = Client::new(&client);
sourcepub async fn version(&self) -> Result<String>
pub async fn version(&self) -> Result<String>
Returns the pgstac version.
§Examples
use pgstac::Client;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (mut client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
let client = Client::new(&client);
let version = client.version().await.unwrap();
sourcepub async fn context(&self) -> Result<bool>
pub async fn context(&self) -> Result<bool>
Returns the value of the context
pgstac setting.
This setting defaults to “off”. See the pgstac docs for more information on the settings and their meaning.
§Examples
use pgstac::Client;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (mut client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
let client = Client::new(&client);
assert!(!client.context().await.unwrap());
sourcepub async fn set_context(&self, enable: bool) -> Result<()>
pub async fn set_context(&self, enable: bool) -> Result<()>
Sets the value of the context
pgstac setting.
This setting defaults to “off”. See the pgstac docs for more information on the settings and their meaning.
§Examples
use pgstac::Client;
use tokio_postgres::NoTls;
let config = "postgresql://username:password@localhost:5432/postgis";
let (mut client, connection) = tokio_postgres::connect(config, NoTls).await.unwrap();
let client = Client::new(&client);
client.set_context(true).await.unwrap();
sourcepub async fn collections(&self) -> Result<Vec<Collection>>
pub async fn collections(&self) -> Result<Vec<Collection>>
Fetches all collections.
sourcepub async fn collection(&self, id: &str) -> Result<Option<Collection>>
pub async fn collection(&self, id: &str) -> Result<Option<Collection>>
Fetches a collection by id.
sourcepub async fn add_collection(&self, collection: Collection) -> Result<()>
pub async fn add_collection(&self, collection: Collection) -> Result<()>
Adds a collection.
sourcepub async fn upsert_collection(&self, collection: Collection) -> Result<()>
pub async fn upsert_collection(&self, collection: Collection) -> Result<()>
Adds or updates a collection.
sourcepub async fn update_collection(&self, collection: Collection) -> Result<()>
pub async fn update_collection(&self, collection: Collection) -> Result<()>
Updates a collection.
sourcepub async fn delete_collection(&self, id: &str) -> Result<()>
pub async fn delete_collection(&self, id: &str) -> Result<()>
Deletes a collection.
sourcepub async fn update_item(&self, item: Item) -> Result<()>
pub async fn update_item(&self, item: Item) -> Result<()>
Updates an item.
sourcepub async fn upsert_item(&self, item: Item) -> Result<()>
pub async fn upsert_item(&self, item: Item) -> Result<()>
Upserts an item.
sourcepub async fn upsert_items(&self, items: &[Item]) -> Result<()>
pub async fn upsert_items(&self, items: &[Item]) -> Result<()>
Upserts items.