Struct stac_api::UrlBuilder
source · pub struct UrlBuilder { /* private fields */ }
Expand description
Builds urls on a root url.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test/api/v1").unwrap();
assert_eq!(
url_builder.items("my-great-collection").unwrap().as_str(),
"http://stac-api-rs.test/api/v1/collections/my-great-collection/items"
);
Implementations§
source§impl UrlBuilder
impl UrlBuilder
sourcepub fn new(url: &str) -> Result<UrlBuilder, ParseError>
pub fn new(url: &str) -> Result<UrlBuilder, ParseError>
Creates a new url builder.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
sourcepub fn root(&self) -> &Url
pub fn root(&self) -> &Url
Returns the root url.
The root url always has a trailing slash, even if the builder was created without one.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(url_builder.root().as_str(), "http://stac-api-rs.test/");
sourcepub fn collections(&self) -> &Url
pub fn collections(&self) -> &Url
Returns the collections url.
This url is created when the builder is created, so it can’t error.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(url_builder.collections().as_str(), "http://stac-api-rs.test/collections");
sourcepub fn collection(&self, id: &str) -> Result<Url, ParseError>
pub fn collection(&self, id: &str) -> Result<Url, ParseError>
Returns a collection url.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(
url_builder.collection("a-collection").unwrap().as_str(),
"http://stac-api-rs.test/collections/a-collection"
);
sourcepub fn items(&self, id: &str) -> Result<Url, ParseError>
pub fn items(&self, id: &str) -> Result<Url, ParseError>
Returns an items url.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(
url_builder.items("a-collection").unwrap().as_str(),
"http://stac-api-rs.test/collections/a-collection/items"
);
sourcepub fn conformance(&self) -> &Url
pub fn conformance(&self) -> &Url
Returns the conformance url.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(
url_builder.conformance().as_str(),
"http://stac-api-rs.test/conformance"
);
sourcepub fn service_desc(&self) -> &Url
pub fn service_desc(&self) -> &Url
Returns the service-desc url.
Examples
let url_builder = UrlBuilder::new("http://stac-api-rs.test").unwrap();
assert_eq!(
url_builder.service_desc().as_str(),
"http://stac-api-rs.test/api"
);
Trait Implementations§
source§impl Clone for UrlBuilder
impl Clone for UrlBuilder
source§fn clone(&self) -> UrlBuilder
fn clone(&self) -> UrlBuilder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more