manganis_core/
folder.rs

1use const_serialize::SerializeConst;
2
3use crate::{AssetOptions, AssetOptionsBuilder};
4
5/// The builder for a folder asset.
6#[derive(
7    Debug,
8    Eq,
9    PartialEq,
10    PartialOrd,
11    Clone,
12    Copy,
13    Hash,
14    SerializeConst,
15    serde::Serialize,
16    serde::Deserialize,
17)]
18pub struct FolderAssetOptions {}
19
20impl Default for FolderAssetOptions {
21    fn default() -> Self {
22        Self::default()
23    }
24}
25
26impl FolderAssetOptions {
27    /// Create a new folder asset builder
28    pub const fn new() -> AssetOptionsBuilder<FolderAssetOptions> {
29        AssetOptions::folder()
30    }
31
32    /// Create a default folder asset options
33    pub const fn default() -> Self {
34        Self {}
35    }
36}
37
38impl AssetOptions {
39    /// Create a new folder asset builder
40    ///
41    /// ```rust
42    /// # use manganis::{asset, Asset, AssetOptions};
43    /// const _: Asset = asset!("/assets", AssetOptions::folder());
44    /// ```
45    pub const fn folder() -> AssetOptionsBuilder<FolderAssetOptions> {
46        AssetOptionsBuilder::variant(FolderAssetOptions::default())
47    }
48}
49
50impl AssetOptionsBuilder<FolderAssetOptions> {
51    /// Convert the options into options for a generic asset
52    pub const fn into_asset_options(self) -> AssetOptions {
53        AssetOptions {
54            add_hash: false,
55            variant: crate::AssetVariant::Folder(self.variant),
56        }
57    }
58}