pub struct LinkBuilder { /* private fields */ }
Expand description
A builder for a WebFinger link.
This is used to construct a Link
with the desired fields.
Implementations§
Source§impl LinkBuilder
impl LinkBuilder
Sourcepub fn new<R: Into<Rel>>(rel: R) -> Self
pub fn new<R: Into<Rel>>(rel: R) -> Self
Create a new link builder with the given relation type.
Sourcepub fn type<S: Into<String>>(self, type: S) -> Self
pub fn type<S: Into<String>>(self, type: S) -> Self
Set the media type of the link.
Defined in RFC 7033 Section 4.4.4.2
Sourcepub fn href<S: Into<String>>(self, href: S) -> Self
pub fn href<S: Into<String>>(self, href: S) -> Self
Set the target URI of the link.
Defined in RFC 7033 Section 4.4.4.3
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}
Sourcepub fn title<L: Into<String>, V: Into<String>>(
self,
language: L,
value: V,
) -> Self
pub fn title<L: Into<String>, V: Into<String>>( self, language: L, value: V, ) -> Self
Add a single title for the the link.
Defined in RFC 7033 Section 4.4.4.4
Sourcepub fn titles(self, titles: Vec<Title>) -> Self
pub fn titles(self, titles: Vec<Title>) -> Self
Set the titles of the link.
Defined in RFC 7033 Section 4.4.4.4
Sourcepub fn property<K: Into<String>, V: Into<Option<String>>>(
self,
key: K,
value: V,
) -> Self
pub fn property<K: Into<String>, V: Into<Option<String>>>( self, key: K, value: V, ) -> Self
Add a single property to the link.
Defined in RFC 7033 Section 4.4.4.5
Sourcepub fn properties(self, properties: HashMap<String, Option<String>>) -> Self
pub fn properties(self, properties: HashMap<String, Option<String>>) -> Self
Set the properties of the link.
Defined in RFC 7033 Section 4.4.4.5
Trait Implementations§
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.
Auto Trait Implementations§
impl Freeze for LinkBuilder
impl RefUnwindSafe for LinkBuilder
impl Send for LinkBuilder
impl Sync for LinkBuilder
impl Unpin for LinkBuilder
impl UnwindSafe for LinkBuilder
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