1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/// Implemented by all three STAC objects, the [Href] trait allows getting and setting an object's href.
///
/// Though the 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, Href};
///
/// let item = Item::new("an-id");
/// assert!(item.href().is_none());
/// let item: Item = stac::read("examples/simple-item.json").unwrap();
/// assert!(item.href().is_some());
/// ```
pub trait Href {
/// Gets this object's href.
///
/// # Examples
///
/// ```
/// use stac::{Href, Item};
///
/// let item: Item = stac::read("examples/simple-item.json").unwrap();
/// assert_eq!(item.href(), Some("examples/simple-item.json"));
/// ```
fn href(&self) -> Option<&str>;
/// Sets this object's href.
///
/// # Examples
///
/// ```
/// use stac::{Item, Href};
///
/// let mut item = Item::new("an-id");
/// item.set_href("http://stac.test/item.json");
/// ```
fn set_href(&mut self, href: impl ToString);
/// Clears this object's href.
///
/// # Examples
///
/// ```
/// use stac::{Href, Item};
///
/// let mut item: Item = stac::read("examples/simple-item.json").unwrap();
/// item.clear_href();
/// assert!(item.href().is_none());
/// ```
fn clear_href(&mut self);
}