Struct LinkBuilder

Source
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

Source

pub fn new<R: Into<Rel>>(rel: R) -> Self

Create a new link builder with the given relation type.

Source

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

Source

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
Hide additional 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}
Source

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

Source

pub fn titles(self, titles: Vec<Title>) -> Self

Set the titles of the link.

Defined in RFC 7033 Section 4.4.4.4

Source

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

Source

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

Source

pub fn build(self) -> Link

Build the link.

This can be omitted if the link is being converted to a Link directly from the builder as LinkBuilder also implements From<LinkBuilder> for Link.

Trait Implementations§

Source§

fn from(builder: LinkBuilder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Result<U, <U as TryFrom<T>>::Error>> + 'async_trait>>
where T: 'async_trait,

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,