pub struct Links(/* private fields */);Expand description
An ordered collection of Link values.
Preserves insertion order; duplicate rel values are allowed (some APIs
return multiple "related" links). Use Links::find to look up the
first link with a given rel.
Implementations§
Source§impl Links
impl Links
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty Links collection.
use api_bones::links::Links;
let links = Links::new();
assert!(links.is_empty());Sourcepub fn push(self, link: Link) -> Self
pub fn push(self, link: Link) -> Self
Append a Link and return self (builder-style).
use api_bones::links::{Link, Links};
let links = Links::new()
.push(Link::self_link("/a"))
.push(Link::next("/b"));
assert_eq!(links.len(), 2);Sourcepub fn find(&self, rel: &str) -> Option<&Link>
pub fn find(&self, rel: &str) -> Option<&Link>
Return the first Link whose rel matches rel, if any.
use api_bones::links::{Link, Links};
let links = Links::new()
.push(Link::self_link("/a"))
.push(Link::next("/b"));
assert_eq!(links.find("next").unwrap().href, "/b");
assert!(links.find("prev").is_none());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Links
impl<'de> Deserialize<'de> for Links
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
Source§impl IntoIterator for Links
impl IntoIterator for Links
impl Eq for Links
impl StructuralPartialEq for Links
Auto Trait Implementations§
impl Freeze for Links
impl RefUnwindSafe for Links
impl Send for Links
impl Sync for Links
impl Unpin for Links
impl UnsafeUnpin for Links
impl UnwindSafe for Links
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