* add support for external assets * fix playwright tests * add more documentation to with_hash_suffix * restore external asset hashing tests * Update gtk workflow dependencies * fix doc test * multiple versions of libgtk * clear dx in playwright tests * fix fullstack caching test * try without apt cache * cache everything except libxdo-dev * revert ci changes * fix wasm asset options * fix merge conflict * recommend the used attribute instead * Move options to AssetOptionsBuilder * Don't deprecate non-canonical new asset options functions --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
59 lines
1.3 KiB
Rust
59 lines
1.3 KiB
Rust
use const_serialize::SerializeConst;
|
|
|
|
use crate::{AssetOptions, AssetOptionsBuilder};
|
|
|
|
/// The builder for a folder asset.
|
|
#[derive(
|
|
Debug,
|
|
Eq,
|
|
PartialEq,
|
|
PartialOrd,
|
|
Clone,
|
|
Copy,
|
|
Hash,
|
|
SerializeConst,
|
|
serde::Serialize,
|
|
serde::Deserialize,
|
|
)]
|
|
pub struct FolderAssetOptions {}
|
|
|
|
impl Default for FolderAssetOptions {
|
|
fn default() -> Self {
|
|
Self::default()
|
|
}
|
|
}
|
|
|
|
impl FolderAssetOptions {
|
|
/// Create a new folder asset builder
|
|
pub const fn new() -> AssetOptionsBuilder<FolderAssetOptions> {
|
|
AssetOptions::folder()
|
|
}
|
|
|
|
/// Create a default folder asset options
|
|
pub const fn default() -> Self {
|
|
Self {}
|
|
}
|
|
}
|
|
|
|
impl AssetOptions {
|
|
/// Create a new folder asset builder
|
|
///
|
|
/// ```rust
|
|
/// # use manganis::{asset, Asset, AssetOptions};
|
|
/// const _: Asset = asset!("/assets", AssetOptions::folder());
|
|
/// ```
|
|
pub const fn folder() -> AssetOptionsBuilder<FolderAssetOptions> {
|
|
AssetOptionsBuilder::variant(FolderAssetOptions::default())
|
|
}
|
|
}
|
|
|
|
impl AssetOptionsBuilder<FolderAssetOptions> {
|
|
/// Convert the options into options for a generic asset
|
|
pub const fn into_asset_options(self) -> AssetOptions {
|
|
AssetOptions {
|
|
add_hash: false,
|
|
variant: crate::AssetVariant::Folder(self.variant),
|
|
}
|
|
}
|
|
}
|