1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
//! Asynchronous I/O for [STAC](https://stacspec.org/), built on [stac-rs](https://github.com/stac-utils/stac-rs)
//!
//! # Examples
//!
//! Read a single STAC item:
//!
//! ```
//! # tokio_test::block_on(async {
//! let item: stac::Item = stac_async::read("data/simple-item.json").await.unwrap();
//! # })
//! ```
//!
//! Build an API client to read from a [STAC API](https://github.com/radiantearth/stac-api-spec):
//!
//! ```no_run
//! use futures_util::StreamExt;
//! let url = "https://planetary-computer.microsoft.com/api/stac/v1";
//! let api_client = stac_async::ApiClient::new(url).unwrap();
//! # tokio_test::block_on(async {
//! // Get the first sentinel2 item using an asynchronous stream
//! let items = api_client.items("sentinel2-l2a", None).await.unwrap();
//! tokio::pin!(items);
//! let item = items.next().await.unwrap().unwrap();
//! # })
//! ```
//!
//! Download assets from an item:
//!
//! ```no_run
//! use stac_async::Download;
//! # tokio_test::block_on(async {
//! let item: stac::Item = stac_async::read("data/simple-item.json").await.unwrap();
//! item.download("target-directory").await.unwrap();
//! # })
//! ```
#![deny(
elided_lifetimes_in_paths,
explicit_outlives_requirements,
keyword_idents,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
missing_debug_implementations,
missing_docs,
non_ascii_idents,
noop_method_call,
pointer_structural_match,
rust_2021_incompatible_closure_captures,
rust_2021_incompatible_or_patterns,
rust_2021_prefixes_incompatible_syntax,
rust_2021_prelude_collisions,
single_use_lifetimes,
trivial_casts,
trivial_numeric_casts,
unreachable_pub,
unsafe_code,
unsafe_op_in_unsafe_fn,
unused_crate_dependencies,
unused_extern_crates,
unused_import_braces,
unused_lifetimes,
unused_qualifications,
unused_results
)]
mod api_client;
mod client;
pub mod download;
mod error;
mod io;
pub use {
api_client::ApiClient,
client::Client,
download::{download, Download, Downloader},
error::Error,
io::{read, read_json, write_json_to_path},
};
/// Crate-specific result type.
pub type Result<T> = std::result::Result<T, Error>;
#[cfg(test)]
use tokio_test as _; // used for doc tests
// From https://github.com/rust-lang/cargo/issues/383#issuecomment-720873790,
// may they be forever blessed.
#[cfg(doctest)]
mod readme {
macro_rules! external_doc_test {
($x:expr) => {
#[doc = $x]
extern "C" {}
};
}
external_doc_test!(include_str!("../README.md"));
}