Struct pgstac::Client

source ·
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>

source

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);
source

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();
source

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());
source

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();
source

pub async fn collections(&self) -> Result<Vec<Collection>>

Fetches all collections.

source

pub async fn collection(&self, id: &str) -> Result<Option<Collection>>

Fetches a collection by id.

source

pub async fn add_collection(&self, collection: Collection) -> Result<()>

Adds a collection.

source

pub async fn upsert_collection(&self, collection: Collection) -> Result<()>

Adds or updates a collection.

source

pub async fn update_collection(&self, collection: Collection) -> Result<()>

Updates a collection.

source

pub async fn delete_collection(&self, id: &str) -> Result<()>

Deletes a collection.

source

pub async fn item(&self, id: &str, collection: &str) -> Result<Option<Item>>

Fetches an item.

source

pub async fn add_item(&self, item: Item) -> Result<()>

Adds an item.

source

pub async fn add_items(&self, items: &[Item]) -> Result<()>

Adds items.

source

pub async fn update_item(&self, item: Item) -> Result<()>

Updates an item.

source

pub async fn upsert_item(&self, item: Item) -> Result<()>

Upserts an item.

source

pub async fn upsert_items(&self, items: &[Item]) -> Result<()>

Upserts items.

source

pub async fn search(&self, search: Search) -> Result<Page>

Searches for items.

Trait Implementations§

source§

impl<'a, C> Debug for Client<'a, C>
where C: GenericClient + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, C> Freeze for Client<'a, C>

§

impl<'a, C> RefUnwindSafe for Client<'a, C>
where C: RefUnwindSafe,

§

impl<'a, C> Send for Client<'a, C>
where C: Sync,

§

impl<'a, C> Sync for Client<'a, C>
where C: Sync,

§

impl<'a, C> Unpin for Client<'a, C>

§

impl<'a, C> UnwindSafe for Client<'a, C>
where C: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more