pub struct TrunkAssetManifest {
pub public_url: String,
pub html: String,
pub assets: Vec<TrunkAssetReference>,
pub wasm: Vec<TrunkWasmBundle>,
pub document_assets: Vec<TrunkDocumentAsset>,
}Expand description
Assets produced by Trunk for one frontend build.
Fields§
§public_url: StringConfigured public URL prefix.
html: StringFinalized HTML output filename.
assets: Vec<TrunkAssetReference>External assets in source HTML order.
wasm: Vec<TrunkWasmBundle>Rust/WASM bundles; empty when the application has no Rust frontend.
document_assets: Vec<TrunkDocumentAsset>Exact markup Trunk generated into its HTML output.
Implementations§
Source§impl TrunkAssetManifest
impl TrunkAssetManifest
Sourcepub fn read_from_env() -> Result<TrunkAssetManifest, ViewError>
pub fn read_from_env() -> Result<TrunkAssetManifest, ViewError>
Reads the manifest path supplied by a Serenade mode command.
Call once during application startup, not once per request.
§Errors
Returns an error when the environment variable is missing or the manifest is missing, malformed, or incompatible.
Sourcepub fn read(path: impl AsRef<Path>) -> Result<TrunkAssetManifest, ViewError>
pub fn read(path: impl AsRef<Path>) -> Result<TrunkAssetManifest, ViewError>
Reads and validates the manifest once, suitable for build/startup use.
§Errors
Returns an error when the file is missing, malformed, incompatible, or contains invalid asset references.
Sourcepub fn from_json(contents: &[u8]) -> Result<TrunkAssetManifest, ViewError>
pub fn from_json(contents: &[u8]) -> Result<TrunkAssetManifest, ViewError>
Parses and validates Trunk manifest JSON bytes.
§Errors
Returns an error for malformed or incompatible manifests.
Sourcepub fn document_assets(&self) -> Result<DocumentAssets, ViewError>
pub fn document_assets(&self) -> Result<DocumentAssets, ViewError>
Returns the exact markup Trunk generated for the document, grouped by
head and body in Trunk’s order, ready for Document::with_assets.
This includes stylesheets, scripts, icons, inline assets, preloads and the WASM bootstrap, with hashed URLs, SRI attributes and nonce placeholders exactly as Trunk wrote them. Call once at startup.
§Errors
Returns an error for markup Trunk inserted outside the document head or body.
Sourcepub fn validate_output(&self, dist: impl AsRef<Path>) -> Result<(), ViewError>
pub fn validate_output(&self, dist: impl AsRef<Path>) -> Result<(), ViewError>
Validates that every local output referenced by the manifest exists and matches its declared size and enabled SRI digests.
§Errors
Returns an error when a reference escapes the output directory, an artifact is missing or stale, or an integrity digest does not match.
Sourcepub fn resolve_output_file(
&self,
dist: impl AsRef<Path>,
url: &str,
) -> Result<PathBuf, ViewError>
pub fn resolve_output_file( &self, dist: impl AsRef<Path>, url: &str, ) -> Result<PathBuf, ViewError>
Resolves a public URL or request path to the real file it names inside the Trunk output directory, for servers that host the output themselves.
Applies Self::output_path_for_url, then follows symbolic links and
rejects any file whose real location is outside dist, including files
that the manifest does not reference.
§Errors
Returns an error when the URL is not under the public URL, the file is
missing or not a regular file, or it resolves outside dist.
Sourcepub fn output_path_for_url(&self, url: &str) -> Result<PathBuf, ViewError>
pub fn output_path_for_url(&self, url: &str) -> Result<PathBuf, ViewError>
Maps a public asset URL or request path to its path relative to the
Trunk output directory, using the same rules as Self::validate_output.
Servers must use this instead of joining the raw request path onto the
output directory: with a non-root public_url such as /app/, the URL
/app/app.js is the output file app.js. The public URL root itself,
with or without its trailing slash (/app/ or /app), is the HTML
entry point named by Self::html.
§Errors
Returns an error when the URL is not under public_url at a path
boundary, has a query or fragment, or escapes the output directory.
Trait Implementations§
Source§impl Clone for TrunkAssetManifest
impl Clone for TrunkAssetManifest
Source§fn clone(&self) -> TrunkAssetManifest
fn clone(&self) -> TrunkAssetManifest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TrunkAssetManifest
impl Debug for TrunkAssetManifest
Source§impl<'de> Deserialize<'de> for TrunkAssetManifest
impl<'de> Deserialize<'de> for TrunkAssetManifest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrunkAssetManifest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<TrunkAssetManifest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for TrunkAssetManifest
Source§impl PartialEq for TrunkAssetManifest
impl PartialEq for TrunkAssetManifest
impl StructuralPartialEq for TrunkAssetManifest
Auto Trait Implementations§
impl Forget for TrunkAssetManifest
impl Freeze for TrunkAssetManifest
impl Move for TrunkAssetManifest
impl RefUnwindSafe for TrunkAssetManifest
impl Send for TrunkAssetManifest
impl Sync for TrunkAssetManifest
impl Unpin for TrunkAssetManifest
impl UnsafeUnpin for TrunkAssetManifest
impl UnwindSafe for TrunkAssetManifest
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
submit event.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more