Skip to main content

Manifest

Trait Manifest 

Source
pub trait Manifest<'a> {
    // Required methods
    fn boxed(&self) -> DynManifest<'a>;
    fn base(&self) -> Cow<'a, str>;
    fn resolve_output(&self, key: &str) -> Option<Cow<'a, str>>;
    fn iter_keys(&self) -> Box<dyn Iterator<Item = &str> + '_>;
    fn iter_outputs(&self) -> Box<dyn Iterator<Item = &str> + '_>;
    fn chunk(&self, output: &str) -> Option<Cow<'a, ManifestChunk<'a>>>;

    // Provided method
    fn chunk_by_key(&self, key: &str) -> Option<Cow<'a, ManifestChunk<'a>>> { ... }
}
Expand description

Trait, that helps query chunks in Vite manifest.

See Manifest derive and ManifestChunk.

Required Methods§

Source

fn boxed(&self) -> DynManifest<'a>

Returns generic boxed manifest.

Usually used in integrations and functions, that require Manifest.

Source

fn base(&self) -> Cow<'a, str>

Get base URL of Manifest. By default, it’s /.

Base URL - is an prefix before paths. This option is usually used in framework integrations and HtmlIntegration.

Source

fn resolve_output(&self, key: &str) -> Option<Cow<'a, str>>

Get output_filename from manifest key.

assert_eq!(MyViteStatic.resolve_output("src/main.tsx").unwrap(), "main.HASH.js");
Source

fn iter_keys(&self) -> Box<dyn Iterator<Item = &str> + '_>

Iterator over manifest keys (AKA input filenames, e.g. “src/main.tsx”).

MyViteStatic.iter_keys();
// returns iterator over keys (e.g. "src/main.tsx", "src/style.scss", "_shared.HASH.js", ...)
Source

fn iter_outputs(&self) -> Box<dyn Iterator<Item = &str> + '_>

Iterator over manifest outputs (AKA output filenames, e.g. “main.HASH.js”).

MyViteStatic.iter_outputs();
// returns iterator over output filenames (e.g. "main.HASH.js", "chunks/_shared.HASH.js", ...)
Source

fn chunk(&self, output: &str) -> Option<Cow<'a, ManifestChunk<'a>>>

Get ManifestChunk from output filename.

let chunk = MyViteStatic.chunk("main.HASH.js").unwrap(); // returns Option<ManifestChunk>

assert_eq!(chunk.key, "src/main.tsx");
assert_eq!(chunk.file, "main.HASH.js");

Provided Methods§

Source

fn chunk_by_key(&self, key: &str) -> Option<Cow<'a, ManifestChunk<'a>>>

Get ManifestChunk from manifest key.

let chunk = MyViteStatic.chunk_by_key("src/main.tsx").unwrap(); // returns Option<ManifestChunk>

assert_eq!(chunk.key, "src/main.tsx");
assert_eq!(chunk.file, "main.HASH.js");

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§