stac_io/
read.rs

1use crate::{Format, Readable, Result};
2use stac::SelfHref;
3
4/// Reads a STAC value from an href.
5///
6/// The format will be inferred from the href's extension. If you want to
7/// specify the format, use [Format::read].
8///
9/// # Examples
10///
11/// ```
12/// let item: stac::Item = stac_io::read("examples/simple-item.json").unwrap();
13/// ```
14pub fn read<T: SelfHref + Readable>(href: impl ToString) -> Result<T> {
15    let href = href.to_string();
16    let format = Format::infer_from_href(&href).unwrap_or_default();
17    format.read(href)
18}