Skip to main content

FilesystemLoader

Struct FilesystemLoader 

Source
pub struct FilesystemLoader { /* private fields */ }

Implementations§

Source§

impl FilesystemLoader

Source

pub fn new(allowed_roots: Vec<PathBuf>) -> FilesystemLoader

Construct a loader scoped to the given root directories. Files outside these roots — even when the href is absolute and points at them directly — will be refused.

Pass specific directories like the stylesheet’s own folder or /usr/share/xml; never pass /. An empty list means “refuse everything,” which is the safest choice for an untrusted stylesheet that’s not expected to import.

Trait Implementations§

Source§

impl Debug for FilesystemLoader

Source§

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

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

impl Default for FilesystemLoader

Source§

fn default() -> FilesystemLoader

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

impl Loader for FilesystemLoader

Source§

fn load_parsed( &self, href: &str, base: Option<&str>, ) -> Result<Arc<Document>, XsltError>

Cached parse for repeated lookups of the same on-disk file. Keys on the canonical path so foo/../foo.xml and foo.xml (resolved against the same base) share a cache entry. Misses fall through to load + parse_str then populate the cache.

Source§

fn enumerate(&self, base: Option<&str>) -> Vec<String>

Walk every file under the loader’s allowed roots, returning hrefs relative to base’s parent directory. Only files whose extension is a typical XML / text resource are returned, to keep speculative pre-loading from chewing through every binary the test directory happens to contain. Bounded depth (16) so a stray symlink loop can’t hang the runtime.

Source§

fn load(&self, href: &str, base: Option<&str>) -> Result<String, XsltError>

Load href’s contents. Returns the raw source as a UTF-8 string. Implementations should resolve href against base when href is relative.
Source§

fn resolve(&self, href: &str, base: Option<&str>) -> Result<String, XsltError>

Compute the base URI to use for files imported FROM the resource at href. Default: returns href itself (used as the base for the next level of resolution).

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> Same for T

Source§

type Output = T

Should always be Self
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.