Struct moxie_dom::elements::metadata::LinkBuilder[][src]

#[must_use = "needs to be built"]pub struct LinkBuilder { /* fields omitted */ }

The HTML External Resource Link element (<link>) specifies relationships between the current document and an external resource. This element is most commonly used to link to stylesheets, but is also used to establish site icons (both “favicon” style icons and icons for the home screen and apps on mobile devices) among other things.

A type for initializing the element’s attributes before calling build.


impl LinkBuilder[src]

pub fn as_(self, to_set: impl ToString) -> Self[src]

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

pub fn crossorigin(self, to_set: impl ToString) -> Self[src]

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.

pub fn disabled(self, to_set: impl ToString) -> Self[src]

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.

pub fn href(self, to_set: impl ToString) -> Self[src]

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

pub fn hreflang(self, to_set: impl ToString) -> Self[src]

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.

pub fn media(self, to_set: impl ToString) -> Self[src]

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.

pub fn rel(self, to_set: impl ToString) -> Self[src]

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.

pub fn sizes(self, to_set: impl ToString) -> Self[src]

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

pub fn title(self, to_set: impl ToString) -> Self[src]

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.

pub fn type_(self, to_set: impl ToString) -> Self[src]

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.

Trait Implementations

impl ElementBuilder for LinkBuilder[src]

impl<E> EventTarget<E> for LinkBuilder where
    E: GlobalEvent

impl GlobalEventHandler for LinkBuilder[src]

impl HtmlElementBuilder for LinkBuilder[src]

impl NodeBuilder for LinkBuilder[src]

type Output = Link

The type of the DOM node

fn build(self) -> Link[src]

Initialize the element with all of the attributes so far.

impl NodeWrapper for LinkBuilder[src]

Auto Trait Implementations

impl !RefUnwindSafe for LinkBuilder

impl !Send for LinkBuilder

impl !Sync for LinkBuilder

impl Unpin for LinkBuilder

impl !UnwindSafe for LinkBuilder

Blanket Implementations

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

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

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

impl<N> Child for N where
    N: NodeWrapper

impl<T> Downcast for T where
    T: Any

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.