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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//! Astrelis Assets - Type-safe asset management system
//!
//! This crate provides a comprehensive asset management system with:
//! - Typed handles with generational IDs for O(1) access and use-after-free protection
//! - Multiple asset sources (disk, memory, raw bytes)
//! - Pluggable asset loaders
//! - Async/background loading
//! - Hot-reload support (disk and memory)
//! - GPU resource integration hooks
//! - Event system for change detection
//!
//! # Architecture Overview
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────┐
//! │ AssetServer │
//! │ - Coordinates all asset operations │
//! │ - Manages type-erased storage │
//! │ - Dispatches to loaders │
//! └───────────────────────────┬─────────────────────────────────────┘
//! │
//! ┌──────────────────┼──────────────────┐
//! ▼ ▼ ▼
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │ Assets<Tex> │ │Assets<Shader│ │Assets<Audio>│
//! │ SparseSet │ │ SparseSet │ │ SparseSet │
//! └──────┬──────┘ └──────┬──────┘ └──────┬──────┘
//! │ │ │
//! ▼ ▼ ▼
//! ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
//! │AssetEntry<T>│ │AssetEntry<T>│ │AssetEntry<T>│
//! │ - state │ │ - state │ │ - state │
//! │ - version │ │ - version │ │ - version │
//! │ - refcount │ │ - refcount │ │ - refcount │
//! └─────────────┘ └─────────────┘ └─────────────┘
//! ```
//!
//! # Quick Start
//!
//! ```ignore
//! use astrelis_assets::prelude::*;
//!
//! // Create the asset server
//! let mut server = AssetServer::new();
//!
//! // Register a loader for textures
//! server.register_loader::<Texture>(TextureLoader::new());
//!
//! // Load an asset from disk
//! let handle: Handle<Texture> = server.load("textures/player.png");
//!
//! // Check if ready and use
//! if let Some(texture) = server.get(&handle) {
//! // Use the texture...
//! }
//!
//! // Poll for events
//! for event in server.drain_events() {
//! match event {
//! AssetEvent::Created { handle, .. } => { /* ... */ }
//! AssetEvent::Modified { handle, .. } => { /* ... */ }
//! AssetEvent::Removed { handle, .. } => { /* ... */ }
//! }
//! }
//! ```
// Re-export core types
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
/// Prelude module for convenient imports
use Any;
/// Marker trait for types that can be managed as assets.
///
/// This trait combines `Any` (for type erasure) with `Send + Sync` (for thread safety).
/// Types implementing this trait can be loaded, stored, and hot-reloaded by the asset system.
///
/// # Example
///
/// ```ignore
/// use astrelis_assets::Asset;
///
/// #[derive(Debug)]
/// pub struct Texture {
/// pub width: u32,
/// pub height: u32,
/// pub data: Vec<u8>,
/// }
///
/// impl Asset for Texture {
/// fn type_name() -> &'static str {
/// "Texture"
/// }
/// }
/// ```