1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use fs;
use crate::;
/// A generic loader for binary assets with custom deserialization or transformation.
///
/// Scans for files matching the glob under the given base path, computes a content
/// hash, and invokes a user-supplied function to produce a typed `T` from the raw bytes.
///
/// ### Parameters
/// - `path_base`: The base directory for resolving the glob.
/// - `path_glob`: Glob pattern (relative to `path_base`) identifying the assets.
/// - `func`: A function that receives the build `Runtime` and the raw file contents,
/// returning a `Result<T>` that will be cached and stored.
///
/// ### Example
/// ```rust
/// use hauchiwa::loader::{Runtime, glob_assets};
///
/// fn count_bytes(_: Runtime, bytes: Vec<u8>) -> anyhow::Result<usize> {
/// Ok(bytes.len())
/// }
///
/// let loader = glob_assets("src/data", "**/*.bin", count_bytes);
/// ```
///
/// ### Output
/// Produces a [`Loader`] that stores a content-hashed instance of `T` per asset.
///
/// ### Notes
/// - Files are hashed and compared by content, not path.
/// - `func` is executed lazily per file during load.
/// - `func` must be deterministic and free of side effects for reproducibility