pub struct ApiClient { /* private fields */ }
👎Deprecated: use
stac
instead of stac-async
, which is deprecated and will receive no further updatesExpand description
A client for interacting with STAC APIs.
Implementations§
Source§impl ApiClient
impl ApiClient
Sourcepub fn new(url: &str) -> Result<ApiClient>
👎Deprecated: use stac
instead of stac-async
, which is deprecated and will receive no further updates
pub fn new(url: &str) -> Result<ApiClient>
stac
instead of stac-async
, which is deprecated and will receive no further updatesCreates a new API client.
§Examples
let client = ApiClient::new("https://planetarycomputer.microsoft.com/api/stac/v1").unwrap();
Sourcepub fn with_client(client: Client, url: &str) -> Result<ApiClient>
👎Deprecated: use stac
instead of stac-async
, which is deprecated and will receive no further updates
pub fn with_client(client: Client, url: &str) -> Result<ApiClient>
stac
instead of stac-async
, which is deprecated and will receive no further updatesCreates a new API client with the given Client.
Useful if you want to customize the behavior of the underlying Client
,
as documented in Client::new.
§Examples
use stac_async::{Client, ApiClient};
let client = Client::new();
let api_client = ApiClient::with_client(client, "https://earth-search.aws.element84.com/v1/").unwrap();
Sourcepub async fn collection(&self, id: &str) -> Result<Option<Collection>>
👎Deprecated: use stac
instead of stac-async
, which is deprecated and will receive no further updates
pub async fn collection(&self, id: &str) -> Result<Option<Collection>>
stac
instead of stac-async
, which is deprecated and will receive no further updatesReturns a single collection.
§Examples
let client = ApiClient::new("https://planetarycomputer.microsoft.com/api/stac/v1").unwrap();
let collection = client.collection("sentinel-2-l2a").await.unwrap().unwrap();
Sourcepub async fn items(
&self,
id: &str,
items: impl Into<Option<Items>>,
) -> Result<impl Stream<Item = Result<Item>>>
👎Deprecated: use stac
instead of stac-async
, which is deprecated and will receive no further updates
pub async fn items( &self, id: &str, items: impl Into<Option<Items>>, ) -> Result<impl Stream<Item = Result<Item>>>
stac
instead of stac-async
, which is deprecated and will receive no further updatesReturns a stream of items belonging to a collection, using the items endpoint.
The items
argument can be used to filter, sort, and otherwise
configure the request.
§Examples
use stac_api::Items;
use stac_async::ApiClient;
use futures_util::stream::StreamExt;
let client = ApiClient::new("https://planetarycomputer.microsoft.com/api/stac/v1").unwrap();
let items = Items {
limit: Some(1),
..Default::default()
};
let items: Vec<_> = client
.items("sentinel-2-l2a", items)
.await
.unwrap()
.map(|result| result.unwrap())
.collect()
.await;
assert_eq!(items.len(), 1);
Sourcepub async fn search(
&self,
search: Search,
) -> Result<impl Stream<Item = Result<Item>>>
👎Deprecated: use stac
instead of stac-async
, which is deprecated and will receive no further updates
pub async fn search( &self, search: Search, ) -> Result<impl Stream<Item = Result<Item>>>
stac
instead of stac-async
, which is deprecated and will receive no further updatesSearches an API, returning a stream of items.
§Examples
use stac_api::Search;
use stac_async::ApiClient;
use futures_util::stream::StreamExt;
let client = ApiClient::new("https://planetarycomputer.microsoft.com/api/stac/v1").unwrap();
let mut search = Search { collections: Some(vec!["sentinel-2-l2a".to_string()]), ..Default::default() };
search.items.limit = Some(1);
let items: Vec<_> = client
.search(search)
.await
.unwrap()
.map(|result| result.unwrap())
.collect()
.await;
assert_eq!(items.len(), 1);
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiClient
impl !RefUnwindSafe for ApiClient
impl Send for ApiClient
impl Sync for ApiClient
impl Unpin for ApiClient
impl !UnwindSafe for ApiClient
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