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§
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 after inlining.
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>
impl<'a> InlineOptions<'a>
Override whether “style” tags should be inlined.
Override whether “style” tags should be kept after processing.
Override whether “link” tags should be kept after processing.
sourcepub fn base_url(self, base_url: Option<Url>) -> Self
pub fn base_url(self, base_url: Option<Url>) -> Self
Set base URL that will be used for loading external stylesheets via relative URLs.
sourcepub fn load_remote_stylesheets(self, load_remote_stylesheets: bool) -> Self
pub fn load_remote_stylesheets(self, load_remote_stylesheets: bool) -> Self
Override whether remote stylesheets should be loaded.
sourcepub fn cache(self, cache: impl Into<Option<StylesheetCache>>) -> Self
pub fn cache(self, cache: impl Into<Option<StylesheetCache>>) -> Self
Set external stylesheet cache.
sourcepub fn preallocate_node_capacity(self, preallocate_node_capacity: usize) -> Self
pub fn preallocate_node_capacity(self, preallocate_node_capacity: usize) -> Self
Set the initial node capacity for HTML tree.
sourcepub fn resolver(self, resolver: Arc<dyn StylesheetResolver>) -> Self
pub fn resolver(self, resolver: Arc<dyn StylesheetResolver>) -> Self
Set the way to resolve stylesheets from various sources.
sourcepub const fn build(self) -> CSSInliner<'a>
pub const fn build(self) -> CSSInliner<'a>
Create a new CSSInliner
instance from this options.