Struct LinkBuilder

Source
pub struct LinkBuilder(/* private fields */);

Implementations§

Source§

impl LinkBuilder

Source

pub fn id(self, value: impl AttributeValue<String>) -> Self

Source

pub fn class(self, value: impl AttributeValue<String>) -> Self

Source

pub fn as_(self, value: impl AttributeValue<String>) -> Self

This attribute is only used when rel=“preload” or rel=“prefetch” has been set on the <link> element. It specifies the type of content being loaded by the <link>, which is necessary for request matching, application of correct content security policy, and setting of correct Accept request header. Furthermore, rel=“preload” uses this as a signal for request prioritization. The table below lists the valid values for this attribute and the elements or resources they apply to.

ValueApplies To
audio<audio> elements
document<iframe> and <frame> elements
embed<embed> elements
fetchfetch, XHR (also requires <link> to contain the crossorigin attribute.)
fontCSS @font-face
image<img> and <picture> elements with srcset or imageset attributes,
SVG <image> elements, CSS *-image rules
object<object> elements
script<script> elements, Worker importScripts
style<link rel=stylesheet> elements, CSS @import
track<track> elements
video<video> elements
workerWorker, SharedWorker
Source

pub fn crossorigin(self, value: impl AttributeValue<String>) -> Self

This enumerated attribute indicates whether CORS must be used when fetching the resource. CORS-enabled images can be reused in the <canvas> element without being tainted. The allowed values are:

  • anonymous: A cross-origin request (i.e. with an Origin HTTP header) is performed, but no credential is sent (i.e. no cookie, X.509 certificate, or HTTP Basic authentication). If the server does not give credentials to the origin site (by not setting the Access-Control-Allow-Origin HTTP header) the resource will be tainted and its usage restricted.
  • use-credentials: A cross-origin request (i.e. with an Origin HTTP header) is performed along with a credential sent (i.e. a cookie, certificate, and/or HTTP Basic authentication is performed). If the server does not give credentials to the origin site (through Access-Control-Allow-Credentials HTTP header), the resource will be tainted and its usage restricted.

If the attribute is not present, the resource is fetched without a CORS request (i.e. without sending the Origin HTTP header), preventing its non-tainted usage. If invalid, it is handled as if the enumerated keyword anonymous was used.

Source

pub fn disabled(self, value: impl AttributeValue<String>) -> Self

For rel=“stylesheet” only, the disabled Boolean attribute indicates whether or not the described stylesheet should be loaded and applied to the document. If disabled is specified in the HTML when it is loaded, the stylesheet will not be loaded during page load. Instead, the stylesheet will be loaded on-demand, if and when the disabled attribute is changed to false or removed.

Once the stylesheet has been loaded, however, changes made to the value of the disabled property no longer have any relationship to the value of the StyleSheet.disabled property. Changing the value of this property instead simply enables and disables the stylesheet form being applied to the document.

This differs from StyleSheet’s disabled property; changing it to true removes the stylesheet from the document’s document.styleSheets list, and doesn’t automatically reload the stylesheet when it’s toggled back to false.

Source

pub fn href(self, value: impl AttributeValue<String>) -> Self

This attribute specifies the URL of the linked resource. A URL can be absolute or relative.

Source

pub fn hreflang(self, value: impl AttributeValue<String>) -> Self

This attribute indicates the language of the linked resource. It is purely advisory. Allowed values are determined by BCP47. Use this attribute only if the href attribute is present.

Source

pub fn media(self, value: impl AttributeValue<String>) -> Self

This attribute specifies the media that the linked resource applies to. Its value must be a media type / media query. This attribute is mainly useful when linking to external stylesheets — it allows the user agent to pick the best adapted one for the device it runs on.

Source

pub fn rel(self, value: impl AttributeValue<String>) -> Self

This attribute names a relationship of the linked document to the current document. The attribute must be a space-separated list of link type values.

Source

pub fn sizes(self, value: impl AttributeValue<String>) -> Self

This attribute defines the sizes of the icons for visual media contained in the resource. It must be present only if the rel contains a value of icon or a non-standard type such as Apple’s apple-touch-icon. It may have the following values:

  • any, meaning that the icon can be scaled to any size as it is in a vector format, like image/svg+xml.
  • a white-space separated list of sizes, each in the format x or X. Each of these sizes must be contained in the resource.

Note: Most icon formats are only able to store one single icon; therefore most of the time the sizes attribute contains only one entry. MS’s ICO format does, as well as Apple’s ICNS. ICO is more ubiquitous, so you should use this format if cross-browser support is a concern (especially for old IE versions).

Source

pub fn title(self, value: impl AttributeValue<String>) -> Self

The title attribute has special semantics on the <link> element. When used on a <link rel="stylesheet"> it defines a preferred or an alternate stylesheet. Incorrectly using it may cause the stylesheet to be ignored.

Source

pub fn type_(self, value: impl AttributeValue<String>) -> Self

This attribute is used to define the type of the content linked to. The value of the attribute should be a MIME type such as text/html, text/css, and so on. The common use of this attribute is to define the type of stylesheet being referenced (such as text/css), but given that CSS is the only stylesheet language used on the web, not only is it possible to omit the type attribute, but is actually now recommended practice. It is also used on rel=“preload” link types, to make sure the browser only downloads file types that it supports.

Source§

impl LinkBuilder

Source

pub fn on_blur( self, f: impl 'static + FnMut(FocusEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_click( self, f: impl 'static + FnMut(MouseEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_change(self, f: impl 'static + FnMut(Event, HtmlLinkElement)) -> Self

Source

pub fn on_dblclick( self, f: impl 'static + FnMut(MouseEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_focusout( self, f: impl 'static + FnMut(FocusEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_input( self, f: impl 'static + FnMut(InputEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_keydown( self, f: impl 'static + FnMut(KeyboardEvent, HtmlLinkElement), ) -> Self

Source

pub fn on_keyup( self, f: impl 'static + FnMut(KeyboardEvent, HtmlLinkElement), ) -> Self

Source

pub fn effect(self, f: impl Effect<HtmlLinkElement>) -> Self

Trait Implementations§

Source§

impl Builder for LinkBuilder

Source§

impl DomElement for LinkBuilder

Source§

impl From<LinkBuilder> for Element

Source§

fn from(builder: LinkBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<LinkBuilder> for ElementBuilder

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, 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, 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.