pub trait ScriptFetcher: 'static {
// Required method
fn fetch(&self, url: &Url) -> Result<String, FetchError>;
// Provided method
fn fetch_for_document(
&self,
url: &Url,
document_url: Option<&Url>,
) -> Result<String, FetchError> { ... }
}Expand description
Trait for synchronously fetching external script sources.
Scripts are fetched synchronously because the HTML spec requires classic
scripts to execute in document order, blocking parsing. Implementations
should provide Self::fetch. The default Self::fetch_for_document
applies file-URL authorization and the source-size limit before returning
source text. An override of fetch_for_document is responsible for
preserving those checks (and any additional policy required by its host).
Required Methods§
Provided Methods§
fn fetch_for_document( &self, url: &Url, document_url: Option<&Url>, ) -> Result<String, FetchError>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".