pub struct Link {
pub href: String,
pub templated: Option<bool>,
pub title: Option<String>,
pub media_type: Option<String>,
pub deprecation: Option<String>,
pub name: Option<String>,
pub profile: Option<String>,
pub hreflang: Option<String>,
}Expand description
A hypermedia link following HAL specification
Links provide navigation between related resources.
§Example
use rustapi_core::hateoas::Link;
let link = Link::new("/users/123")
.title("User details")
.set_templated(false);Fields§
§href: StringThe URI of the linked resource
templated: Option<bool>Whether the href is a URI template
title: Option<String>Human-readable title for the link
media_type: Option<String>Media type hint for the linked resource
deprecation: Option<String>URI indicating the link is deprecated
name: Option<String>Name for differentiating links with the same relation
profile: Option<String>URI of a profile document
hreflang: Option<String>Content-Language of the linked resource
Implementations§
Source§impl Link
impl Link
Sourcepub fn templated(href: impl Into<String>) -> Self
pub fn templated(href: impl Into<String>) -> Self
Create a templated link (URI template)
§Example
use rustapi_core::hateoas::Link;
let link = Link::templated("/users/{id}");Sourcepub fn set_templated(self, templated: bool) -> Self
pub fn set_templated(self, templated: bool) -> Self
Set whether this link is templated
Sourcepub fn media_type(self, media_type: impl Into<String>) -> Self
pub fn media_type(self, media_type: impl Into<String>) -> Self
Set the media type
Sourcepub fn deprecation(self, deprecation_url: impl Into<String>) -> Self
pub fn deprecation(self, deprecation_url: impl Into<String>) -> Self
Mark as deprecated
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Link
impl<'de> Deserialize<'de> for Link
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 From<Link> for LinkOrArray
impl From<Link> for LinkOrArray
impl StructuralPartialEq for Link
Auto Trait Implementations§
impl Freeze for Link
impl RefUnwindSafe for Link
impl Send for Link
impl Sync for Link
impl Unpin for Link
impl UnwindSafe for Link
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Linkable for Twhere
T: Serialize,
impl<T> Linkable for Twhere
T: Serialize,
Source§fn with_links(self) -> Resource<Self>
fn with_links(self) -> Resource<Self>
Wrap this value in a Resource with HATEOAS links