Crate stac_api

source ·
Expand description

Rust implementation of the STAC API specification.

This crate is:

  • Data structures
  • Link building

This crate is not:

  • A server implementation

For a STAC API server written in Rust, based on this crate, see stac-server-rs.

Data structures

Each API endpoint has its own data structure. In some cases, these are light wrappers around stac data structures. In other cases, they can be different – e.g. the /search endpoint may not return Items if the fields extension is used, so the return type is a crate-specific Item struct.

For example, here’s the root structure (a.k.a the landing page):

use stac::Catalog;
use stac_api::Root;
let root = Root {
    catalog: Catalog::new("an-id", "a description"),
    conforms_to: vec!["https://api.stacspec.org/v1.0.0-rc.2/core".to_string()],
};

The LinkBuilder structure can build links to parts of a STAC API. A LinkBuilder is created from a root href:

use stac_api::LinkBuilder;
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();

Link builders provide a variety of methods for building links to all parts of a STAC API:

let link = link_builder.items("a-collection-id", [("limit", "10")]).unwrap();
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/a-collection-id/items?limit=10");

Structs

Object containing an array of Collection objects in the Catalog, and Link relations.
The search-related metadata for the ItemCollection.
Include/exclude fields from item collections.
A crate-specific STAC Item struct.
The return value of the /items and /search endpoints.
Crate-specific link type.
Build links to endpoints in a STAC API.
The root landing page of a STAC API.
The core parameters for STAC search are defined by OAFeat, and STAC adds a few parameters for convenience.
Fields by which to sort results.

Enums

Crate-specific error enum.

Type Definitions

Crate-specific result type.