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
impl Client
sourcepub fn new() -> Result<Client>
pub fn new() -> Result<Client>
Creates a new client with no data sources.
§Examples
use stac_duckdb::Client;
let client = Client::new().unwrap();
sourcepub fn add_href(&mut self, href: impl ToString) -> Result<()>
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();
sourcepub fn from_href(href: impl ToString) -> Result<Client>
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();
sourcepub fn search(&self, search: impl Into<Search>) -> Result<ItemCollection>
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);
sourcepub fn search_to_arrow(
&self,
search: impl Into<Search>,
) -> Result<Vec<Vec<RecordBatch>>>
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
}
}
sourcepub fn search_to_json(
&self,
search: impl Into<Search>,
) -> Result<ItemCollection>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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