pub struct Link {
pub rel: Rel,
pub type: Option<String>,
pub href: Option<String>,
pub titles: Option<Vec<Title>>,
pub properties: Option<HashMap<String, Option<String>>>,
}
Expand description
A link in the WebFinger response.
Defined in RFC 7033 Section 4.4
Fields§
§rel: Rel
The relation type of the link.
Defined in RFC 7033 Section 4.4.4.1
type: Option<String>
The media type of the link.
Defined in RFC 7033 Section 4.4.4.2
href: Option<String>
The target URI of the link.
Defined in RFC 7033 Section 4.4.4.3
titles: Option<Vec<Title>>
The titles of the link.
Defined in RFC 7033 Section 4.4.4.4
properties: Option<HashMap<String, Option<String>>>
The properties of the link.
Defined in RFC 7033 Section 4.4.4.5
Implementations§
Source§impl Link
impl Link
Sourcepub fn builder<R: Into<Rel>>(rel: R) -> LinkBuilder
pub fn builder<R: Into<Rel>>(rel: R) -> LinkBuilder
Create a new LinkBuilder
with the given relation type.
Examples found in repository?
examples/actix.rs (line 56)
47async fn webfinger(request: WebFingerRequest) -> actix_web::Result<WebFingerResponse> {
48 info!("fetching webfinger resource: {:?}", request);
49 let subject = request.resource.to_string();
50 if subject != SUBJECT {
51 let message = format!("{subject} does not exist");
52 return Err(actix_web::error::ErrorNotFound(message))?;
53 }
54 let rel = Rel::new("http://webfinger.net/rel/profile-page");
55 let response = if request.rels.is_empty() || request.rels.contains(&rel) {
56 let link = Link::builder(rel).href(format!("https://example.com/profile/{subject}"));
57 WebFingerResponse::builder(subject).link(link).build()
58 } else {
59 WebFingerResponse::builder(subject).build()
60 };
61 Ok(response)
62}
More examples
examples/axum.rs (line 56)
47async fn webfinger(request: WebFingerRequest) -> axum::response::Result<WebFingerResponse> {
48 info!("fetching webfinger resource: {:?}", request);
49 let subject = request.resource.to_string();
50 if subject != SUBJECT {
51 let message = format!("{subject} does not exist");
52 return Err((StatusCode::NOT_FOUND, message).into());
53 }
54 let rel = Rel::new("http://webfinger.net/rel/profile-page");
55 let response = if request.rels.is_empty() || request.rels.contains(&rel) {
56 let link = Link::builder(rel).href(format!("https://example.com/profile/{subject}"));
57 WebFingerResponse::builder(subject).link(link).build()
58 } else {
59 WebFingerResponse::builder(subject).build()
60 };
61 Ok(response)
62}
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<LinkBuilder> for Link
impl From<LinkBuilder> for Link
Source§fn from(builder: LinkBuilder) -> Self
fn from(builder: LinkBuilder) -> Self
Converts to this type from the input type.
impl Eq for Link
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.