Struct stac_api::LinkBuilder

source ·
pub struct LinkBuilder(_);
Expand description

Build links to endpoints in a STAC API.

Examples

LinkBuilder can be parsed from a string:

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

Note that the root will always have a trailing slash, even if you didn’t provide one:

let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
assert_eq!(link_builder.root().href, "http://stac-api-rs.test/api/v1/");

Implementations§

Returns a root link.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let root = link_builder.root();
assert_eq!(root.rel, "root");
assert_eq!(root.href, "http://stac-api-rs.test/api/v1/");

Returns a root’s self link.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let root = link_builder.root_self();
assert_eq!(root.rel, "self");
assert_eq!(root.href, "http://stac-api-rs.test/api/v1/");

Returns an child link for a collection.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.child_collection("an-id").unwrap();
assert_eq!(link.rel, "child");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/an-id");

Returns a parent link for a collection.

This is just the root url.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.collection_parent();
assert_eq!(link.rel, "parent");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/");

Returns a self link for a collection.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.collection_self("an-id").unwrap();
assert_eq!(link.rel, "self");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/an-id");

Returns an items link for a collection.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.items("an-id", ()).unwrap();
assert_eq!(link.rel, "items");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/an-id/items");

Returns a next items link for a collection.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.next_items("an-id", [("foo", "bar")]).unwrap();
assert_eq!(link.rel, "next");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/an-id/items?foo=bar");

Returns a prev items link for a collection.

Examples
let link_builder: LinkBuilder = "http://stac-api-rs.test/api/v1".parse().unwrap();
let link = link_builder.prev_items("an-id", [("foo", "bar")]).unwrap();
assert_eq!(link.rel, "prev");
assert_eq!(link.href, "http://stac-api-rs.test/api/v1/collections/an-id/items?foo=bar");

Trait Implementations§

Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.