pub struct EmbeddedAssets { /* private fields */ }Expand description
A build-time directory tree of static files.
Implementations§
Source§impl EmbeddedAssets
impl EmbeddedAssets
Sourcepub const fn new(
root: &'static str,
files: &'static [EmbeddedAsset],
) -> EmbeddedAssets
pub const fn new( root: &'static str, files: &'static [EmbeddedAsset], ) -> EmbeddedAssets
Wrap a table produced by generated code.
root is the directory the bytes were compiled from, as written by the
caller (e.g. "wwwroot"), and is used as the disk overlay directory when
no use_spa(...) call named one.
Sourcepub const fn root(&self) -> &'static str
pub const fn root(&self) -> &'static str
The directory the bytes were compiled from, as written by the caller.
Sourcepub const fn files(&self) -> &'static [EmbeddedAsset]
pub const fn files(&self) -> &'static [EmbeddedAsset]
The table, sorted by EmbeddedAsset::path.
Sourcepub fn total_bytes(&self) -> u64
pub fn total_bytes(&self) -> u64
Combined size of the stored payloads, in bytes — what the binary holds.
Sourcepub fn total_raw_bytes(&self) -> u64
pub fn total_raw_bytes(&self) -> u64
Combined size of the files as they exist on disk.
Larger than total_bytes whenever something was
compressed; the difference is what brotli saved.
Sourcepub fn get(&self, path: &str) -> Option<&'static EmbeddedAsset>
pub fn get(&self, path: &str) -> Option<&'static EmbeddedAsset>
Look up path, which must already be normalized: relative, /-separated,
no leading slash and no .. segments.
Sourcepub fn debug_assert_sorted(&self)
pub fn debug_assert_sorted(&self)
Panic in debug builds when the table is not sorted by path, which would
make EmbeddedAssets::get miss entries instead of finding them.
Sourcepub fn shadowed_by(&self, disk_root: &Path) -> Vec<&'static str>
pub fn shadowed_by(&self, disk_root: &Path) -> Vec<&'static str>
Embedded paths for which a same-named file exists under disk_root.
Those are the files an operator is currently overriding. Overrides are the point of the feature, but a stale one silently defeats an updated build, so the host logs them at startup.
Trait Implementations§
Source§impl Clone for EmbeddedAssets
impl Clone for EmbeddedAssets
Source§fn clone(&self) -> EmbeddedAssets
fn clone(&self) -> EmbeddedAssets
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more