pub trait SelfHref {
// Required methods
fn self_href(&self) -> Option<&Href>;
fn self_href_mut(&mut self) -> &mut Option<Href>;
}Expand description
Implemented by all three STAC objects, the SelfHref trait allows getting and setting an object’s href.
Though the self href isn’t part of the data structure, it is useful to know where a given STAC object was read from. Objects created from scratch don’t have an href.
§Examples
use stac::{Item, SelfHref};
let item = Item::new("an-id");
assert!(item.self_href().is_none());
let item: Item = stac::read("examples/simple-item.json").unwrap();
assert!(item.self_href().is_some());Required Methods§
Sourcefn self_href(&self) -> Option<&Href>
fn self_href(&self) -> Option<&Href>
Gets this object’s href.
§Examples
use stac::{SelfHref, Item};
let item: Item = stac::read("examples/simple-item.json").unwrap();
assert!(item.self_href().unwrap().to_string().ends_with("simple-item.json"));Sourcefn self_href_mut(&mut self) -> &mut Option<Href>
fn self_href_mut(&mut self) -> &mut Option<Href>
Returns a mutable reference to this object’s self href.
§Examples
use stac::{Item, SelfHref};
let mut item = Item::new("an-id");
*item.self_href_mut() = Option::Some("./a/relative/path.json".into());