Struct stac_duckdb::Client

source ·
pub struct Client { /* private fields */ }
Expand description

A client for making DuckDB requests for STAC objects.

Implementations§

source§

impl Client

source

pub fn new() -> Result<Client>

Creates a new client with no data sources.

§Examples
use stac_duckdb::Client;

let client = Client::new().unwrap();
source

pub fn add_href(&mut self, href: impl ToString) -> Result<()>

Adds a stac-geoparquet href to this client.

§Examples
use stac_duckdb::Client;

let mut client = Client::new().unwrap();
client.add_href("data/100-sentinel-2-items.parquet").unwrap();
source

pub fn from_href(href: impl ToString) -> Result<Client>

Creates a new client from a path.

§Examples
use stac_duckdb::Client;

let client = Client::from_href("data/100-sentinel-2-items.parquet").unwrap();
source

pub fn search(&self, search: impl Into<Search>) -> Result<ItemCollection>

Searches this client, returning a stac::ItemCollection.

§Examples
use stac_duckdb::Client;
use stac_api::Search;

let client = Client::from_href("data/100-sentinel-2-items.parquet").unwrap();
let item_collection = client.search(Search::default()).unwrap();
assert_eq!(item_collection.items.len(), 100);
source

pub fn search_to_arrow( &self, search: impl Into<Search>, ) -> Result<Vec<Vec<RecordBatch>>>

Searches this client, returning a vector of vectors of all matched record batches.

§Examples

Each inner grouping of record batches comes from the same source table:

use stac_duckdb::Client;
use stac_api::Search;

let client = Client::from_href("data/100-sentinel-2-items.parquet").unwrap();
for record_batches in client.search_to_arrow(Search::default()).unwrap() {
    // Schema can be different between groups of record batches
    for record_batch in record_batches {
        // Each record batch in this scope will have the same schema
    }
}
source

pub fn search_to_json( &self, search: impl Into<Search>, ) -> Result<ItemCollection>

Searches this client, returning a stac_api::ItemCollection.

Use this method if you want JSON that might not be valid STAC items, e.g. if you’ve excluded required fields from the response.

§Examples
use stac_duckdb::Client;
use stac_api::Search;

let client = Client::from_href("data/100-sentinel-2-items.parquet").unwrap();
let item_collection = client.search_to_json(Search::default()).unwrap();
assert_eq!(item_collection.items.len(), 100);

Trait Implementations§

source§

impl Debug for Client

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl !Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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, 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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

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

source§

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>,

source§

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<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool