Skip to main content

FileLoader

Trait FileLoader 

Source
pub trait FileLoader {
    // Required method
    fn load(&self, id: FileId) -> FileResult<Bytes>;
}
Expand description

Provides data for files, backing a FileStore.

If you want to load files in a different way, the first step would be to create your own type that implements FileLoader. For an example, you can take a look at how typst-cli implements it.

If you need even more control, you can also skip the FileStore and implement fully custom logic that directly handles the World::source and World::file requests.

Required Methods§

Source

fn load(&self, id: FileId) -> FileResult<Bytes>

Load the data for the given file ID.

Generally, here you’ll want to match on the root() of the id to check whether the file should be loaded from the project or a package. Then, you’ll load the data at the path id.vpath() in the project / package.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FileLoader for SystemFiles

Available on crate feature system-files only.