pub enum Href {
Url(Url),
String(String),
}Expand description
An href.
Variants§
Url(Url)
A url href.
This can have a file: scheme.
String(String)
A string href.
This is expected to have / delimiters. Windows-style \ delimiters are not supported.
Implementations§
Source§impl Href
impl Href
Sourcepub fn absolute(&self, base: &Href) -> Result<Href>
pub fn absolute(&self, base: &Href) -> Result<Href>
Convert this href into an absolute href using the given base.
§Examples
use stac::Href;
let href = Href::from("./a/b.json").absolute(&"/c/d/e.json".into()).unwrap();
assert_eq!(href, "/c/d/a/b.json");Sourcepub fn relative(&self, base: &Href) -> Result<Href>
pub fn relative(&self, base: &Href) -> Result<Href>
Convert this href into an relative href using to the given base.
§Examples
use stac::Href;
let href = Href::from("/a/b/c.json").relative(&"/a/d.json".into()).unwrap();
assert_eq!(href, "./b/c.json");Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Returns true if this href is absolute.
Urls are always absolute. Strings are absolute if they start with a /.
Sourcepub fn realize(self) -> RealizedHref
pub fn realize(self) -> RealizedHref
If the url scheme is file, convert it to a path string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Href
impl<'de> Deserialize<'de> for Href
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Href
Auto Trait Implementations§
impl Freeze for Href
impl RefUnwindSafe for Href
impl Send for Href
impl Sync for Href
impl Unpin for Href
impl UnwindSafe for Href
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more