pub struct AssetManifest {
pub schema: u8,
pub version: String,
pub contract_hash: String,
pub public_path: String,
pub entries: HashMap<String, AssetEntry>,
}Fields§
§schema: u8§version: String§contract_hash: String§public_path: String§entries: HashMap<String, AssetEntry>Implementations§
Source§impl AssetManifest
impl AssetManifest
Sourcepub fn load(path: impl AsRef<Path>) -> Result<Self, AssetManifestError>
pub fn load(path: impl AsRef<Path>) -> Result<Self, AssetManifestError>
Load and validate a production asset manifest.
§Errors
Returns an error when the file cannot be read, JSON is invalid, the schema is unsupported, or any asset path can escape the asset root.
Sourcepub fn validate(&self) -> Result<(), AssetManifestError>
pub fn validate(&self) -> Result<(), AssetManifestError>
Validate the manifest without reading from disk.
§Errors
Returns an error for unsupported schemas, invalid public prefixes, or unsafe/duplicated asset paths.
pub fn entry(&self, name: &str) -> Option<&AssetEntry>
Sourcepub fn verify_contract(&self, expected: &str) -> Result<(), AssetManifestError>
pub fn verify_contract(&self, expected: &str) -> Result<(), AssetManifestError>
Verify that Rust and browser artifacts were generated from the same contract set.
§Errors
Returns a mismatch error when the expected hash differs.
Sourcepub fn url(&self, asset: &str) -> Result<String, AssetManifestError>
pub fn url(&self, asset: &str) -> Result<String, AssetManifestError>
Produce the public URL for a manifest-owned asset.
§Errors
Returns an error if the path is not present in the manifest.
Sourcepub fn resolve_static(
&self,
root: impl AsRef<Path>,
request_path: &str,
) -> Result<PathBuf, AssetManifestError>
pub fn resolve_static( &self, root: impl AsRef<Path>, request_path: &str, ) -> Result<PathBuf, AssetManifestError>
Resolve an incoming static URL to a file below root.
Only exact files declared by the manifest are resolvable. This avoids using user-controlled paths as general filesystem paths.
§Errors
Returns an error for the wrong URL prefix or an undeclared asset.
Trait Implementations§
Source§impl Clone for AssetManifest
impl Clone for AssetManifest
Source§impl Debug for AssetManifest
impl Debug for AssetManifest
Source§impl<'de> Deserialize<'de> for AssetManifest
impl<'de> Deserialize<'de> for AssetManifest
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for AssetManifest
Source§impl PartialEq for AssetManifest
impl PartialEq for AssetManifest
Source§impl Serialize for AssetManifest
impl Serialize for AssetManifest
impl StructuralPartialEq for AssetManifest
Auto Trait Implementations§
impl Freeze for AssetManifest
impl RefUnwindSafe for AssetManifest
impl Send for AssetManifest
impl Sync for AssetManifest
impl Unpin for AssetManifest
impl UnsafeUnpin for AssetManifest
impl UnwindSafe for AssetManifest
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§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.