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, Conformance};
let root = Root {
    catalog: Catalog::new("an-id", "a description"),
    conformance: Conformance {
        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.collection_to_items("a-collection-id").unwrap();
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/a-collection-id/items");

Structs

  • Object containing an array of Collection objects in the Catalog, and Link relations.
  • To support “generic” clients that want to access multiple OGC API Features implementations - and not “just” a specific API / server, the server has to declare the conformance classes it implements and conforms to.
  • The search-related metadata for the ItemCollection.
  • Include/exclude fields from item collections.
  • GET parameters for the items endpoint from STAC API - Features.
  • The return value of the /items and /search endpoints.
  • Parameters for the items endpoint from STAC API - Features.
  • 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.
  • Builds urls on a root url.

Enums

  • Crate-specific error enum.
  • The language of the filter expression.

Type Definitions

  • A STAC API Item type definition.
  • Crate-specific result type.