pub struct Manifest {
pub entries: Vec<AssetEntry, Global>,
pub local_base: Option<String>,
pub remote_base: Option<String>,
}
Expand description
An asset manifest contains all the information needed to load an asset pack. A manifest is
usually created with Manifest.fromAssets("directory")
, but manifests can also be assembled
programmatically.
Fields
entries: Vec<AssetEntry, Global>
local_base: Option<String>
A base path on the current domain to load this manifest’s assets from, or None.
remote_base: Option<String>
A base URL on another domain to load this manifest’s assets from, or None. May be used to load assets from a CDN, in browsers that support cross-domain requests. If not supported or unset, will fallback to using localBase.
Implementations
sourceimpl Manifest
impl Manifest
pub fn new() -> Manifest
sourcepub fn from_assets(pack_name: String, required: bool) -> Option<Manifest>
pub fn from_assets(pack_name: String, required: bool) -> Option<Manifest>
Gets the manifest of a pack in the asset directory, that was processed at build-time. @param packName The folder name in your assets/ directory. @param required When true and this pack was not found, throw an error. Otherwise None is returned.
sourcepub fn from_assets_localized(
pack_name: String,
locale: Option<String>,
required: bool
) -> Option<Manifest>
pub fn from_assets_localized(
pack_name: String,
locale: Option<String>,
required: bool
) -> Option<Manifest>
Tries to find a pack suffixed with the closest available variant of the locale. For example, fromAssetsLocalized(“foo”, “pt-BR”) will first try to load foo_pt-BR, then foo_pt, then just foo. @param packName The folder name in your assets/ directory. @param locale An RFC 4646 language tag, or None to use the system language. @param required When true and this pack was not found, throw an error. Otherwise None is returned.
sourcepub fn exists(pack_name: String) -> bool
pub fn exists(pack_name: String) -> bool
Returns true if the given named pack was included in the asset directory at build-time.
sourcepub fn add(
&mut self,
name: String,
url: String,
bytes: usize,
format: Option<AssetFormat>
) -> AssetEntry
pub fn add(
&mut self,
name: String,
url: String,
bytes: usize,
format: Option<AssetFormat>
) -> AssetEntry
Adds an asset entry to this manifest. @param name The name of the asset. @param url The URL this asset will be downloaded from. @param bytes The size in bytes. @param format Optionally specified content format, by default infer it from the URL.
sourcepub fn iter(&self) -> impl Iterator<Item = &AssetEntry>
pub fn iter(&self) -> impl Iterator<Item = &AssetEntry>
Iterates over all the assets defined in this manifest.
pub fn len(&self) -> usize
sourcepub fn full_url(&self, entry: AssetEntry) -> String
pub fn full_url(&self, entry: AssetEntry) -> String
Get the full URL to load an asset from. Will prepend localBase or remoteBase depending on cross-domain support.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Manifest
impl Send for Manifest
impl Sync for Manifest
impl Unpin for Manifest
impl UnwindSafe for Manifest
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<'a, T, C, M> Inspect<'a, C, &'a mut C, M> for T
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
fn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.