khora_core/asset/mod.rs
1// Copyright 2025 eraflo
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Provides the foundational traits and primitive types for Khora's asset system.
16//!
17//! This module defines the "common language" for all asset-related operations in the
18//! engine. It contains the core contracts that other crates will implement or use,
19//! but it has no knowledge of how assets are loaded or stored.
20//!
21//! The key components are:
22//! - The [`Asset`] trait: A marker for all types that can be treated as assets.
23//! - Stable, unique identifiers used to reference assets throughout the engine.
24//! - Abstract interfaces for loading and managing assets.
25//!
26//! These low-level primitives are the foundation upon which higher-level systems,
27//! such as an asset database or a virtual file system (VFS), are built in other
28//! crates.
29
30/// Font asset definitions and metadata.
31pub mod font;
32mod handle;
33mod materials;
34mod metadata;
35mod uuid;
36
37pub use handle::AssetHandle as Handle;
38pub use handle::*;
39pub use materials::*;
40pub use metadata::*;
41pub use uuid::*;
42
43/// A marker trait for types that can be managed by the asset system.
44///
45/// This trait's primary purpose is to categorize a type, making it eligible for
46/// use within the engine's asset infrastructure (e.g., in a `Handle<T>`).
47///
48/// The supertraits enforce critical safety guarantees:
49/// - `Send` + `Sync`: The asset type can be safely shared and sent between threads.
50/// This is essential for background loading.
51/// - `'static`: The asset type does not contain any non-static references, ensuring
52/// it can be stored for the lifetime of the application.
53///
54/// # Examples
55///
56/// ```
57/// use khora_core::asset::Asset;
58///
59/// // A simple struct representing a texture.
60/// struct Texture {
61/// // ... fields
62/// }
63///
64/// // By implementing Asset, `Texture` can now be used by the asset system.
65/// impl Asset for Texture {}
66/// ```
67pub trait Asset: Send + Sync + 'static {}