Struct css_inline::InlineOptions

source ·
pub struct InlineOptions<'a> {
    pub inline_style_tags: bool,
    pub keep_style_tags: bool,
    pub keep_link_tags: bool,
    pub base_url: Option<Url>,
    pub load_remote_stylesheets: bool,
    pub cache: Option<Mutex<StylesheetCache>>,
    pub extra_css: Option<Cow<'a, str>>,
    pub preallocate_node_capacity: usize,
    pub resolver: Arc<dyn StylesheetResolver>,
}
Expand description

Configuration options for CSS inlining process.

Fields§

§inline_style_tags: bool

Whether to inline CSS from “style” tags.

Sometimes HTML may include a lot of boilerplate styles, that are not applicable in every scenario and it is useful to ignore them and use extra_css instead.

§keep_style_tags: bool

Keep “style” tags after inlining.

§keep_link_tags: bool

Keep “link” tags after inlining.

§base_url: Option<Url>

Used for loading external stylesheets via relative URLs.

§load_remote_stylesheets: bool

Whether remote stylesheets should be loaded or not.

§cache: Option<Mutex<StylesheetCache>>

External stylesheet cache.

§extra_css: Option<Cow<'a, str>>

Additional CSS to inline.

§preallocate_node_capacity: usize

Pre-allocate capacity for HTML nodes during parsing. It can improve performance when you have an estimate of the number of nodes in your HTML document.

§resolver: Arc<dyn StylesheetResolver>

A way to resolve stylesheets from various sources.

Implementations§

source§

impl<'a> InlineOptions<'a>

source

pub fn inline_style_tags(self, inline_style_tags: bool) -> Self

Override whether “style” tags should be inlined.

source

pub fn keep_style_tags(self, keep_style_tags: bool) -> Self

Override whether “style” tags should be kept after processing.

Override whether “link” tags should be kept after processing.

source

pub fn base_url(self, base_url: Option<Url>) -> Self

Set base URL that will be used for loading external stylesheets via relative URLs.

source

pub fn load_remote_stylesheets(self, load_remote_stylesheets: bool) -> Self

Override whether remote stylesheets should be loaded.

source

pub fn cache(self, cache: impl Into<Option<StylesheetCache>>) -> Self

Set external stylesheet cache.

source

pub fn extra_css(self, extra_css: Option<Cow<'a, str>>) -> Self

Set additional CSS to inline.

source

pub fn preallocate_node_capacity(self, preallocate_node_capacity: usize) -> Self

Set the initial node capacity for HTML tree.

source

pub fn resolver(self, resolver: Arc<dyn StylesheetResolver>) -> Self

Set the way to resolve stylesheets from various sources.

source

pub const fn build(self) -> CSSInliner<'a>

Create a new CSSInliner instance from this options.

Trait Implementations§

source§

impl<'a> Debug for InlineOptions<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for InlineOptions<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> !Freeze for InlineOptions<'a>

§

impl<'a> !RefUnwindSafe for InlineOptions<'a>

§

impl<'a> Send for InlineOptions<'a>

§

impl<'a> Sync for InlineOptions<'a>

§

impl<'a> Unpin for InlineOptions<'a>

§

impl<'a> !UnwindSafe for InlineOptions<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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