pub struct AssetIdRegistry { /* private fields */ }Expand description
Maps forward-slash relative asset paths to their frozen [AssetUUID].
See the module documentation for the lazy-freeze semantics and the engine/editor read/write split.
Implementations§
Source§impl AssetIdRegistry
impl AssetIdRegistry
Sourcepub fn load(project_root: impl Into<PathBuf>) -> Self
pub fn load(project_root: impl Into<PathBuf>) -> Self
Loads the registry for project_root.
A missing or unreadable file yields an empty registry (every path
then resolves to its new_v5 default) — fresh projects and the
pre-registry world both behave exactly as before. A malformed file is
logged and treated as empty rather than failing the whole project open.
Sourcepub fn resolve(&self, rel_fwd: &str) -> AssetUUID
pub fn resolve(&self, rel_fwd: &str) -> AssetUUID
Resolves the UUID for a forward-slash relative path: the frozen entry if
one exists, otherwise the default AssetUUID::new_v5(rel).
This is the read primitive used by the index builder, the runtime, and the pack builder.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of frozen entries (assets whose path has diverged from identity).
Sourcepub fn freeze(&mut self, rel_fwd: &str, uuid: AssetUUID)
pub fn freeze(&mut self, rel_fwd: &str, uuid: AssetUUID)
Explicitly freezes rel_fwd’s identity to uuid.
Authoring-only. Rarely needed directly — Self::rename freezes as part
of the move.
Sourcepub fn rename(&mut self, old_rel: &str, new_rel: &str)
pub fn rename(&mut self, old_rel: &str, new_rel: &str)
Moves the identity of old_rel to new_rel, freezing it in the process.
The new path resolves to the same UUID the old path resolved to
(whether it was already frozen or still on its new_v5 default), so every
existing reference keeps pointing at the asset. Authoring-only.
Sourcepub fn remove(&mut self, rel_fwd: &str)
pub fn remove(&mut self, rel_fwd: &str)
Drops any frozen entry for rel_fwd (e.g. after the asset is deleted).
Authoring-only.
Sourcepub fn file_path(&self) -> PathBuf
pub fn file_path(&self) -> PathBuf
Absolute path of the on-disk registry file
(<project_root>/.khora/asset-registry.ron).
Sourcepub fn ensure_file(&self) -> Result<()>
pub fn ensure_file(&self) -> Result<()>
Writes the registry file if it does not exist yet, so a project has a
visible .khora/asset-registry.ron from first open (confirming that
persistence is wired). No-op when the file already exists. Authoring-only.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Persists the registry to <project_root>/.khora/asset-registry.ron.
Entries are sorted by UUID for deterministic, merge-friendly output, and
the write is atomic (a sibling *.tmp file is written then renamed
over the target) so a crash mid-write cannot corrupt the catalog.
Authoring-only.
Trait Implementations§
Source§impl Clone for AssetIdRegistry
impl Clone for AssetIdRegistry
Source§fn clone(&self) -> AssetIdRegistry
fn clone(&self) -> AssetIdRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AssetIdRegistry
impl RefUnwindSafe for AssetIdRegistry
impl Send for AssetIdRegistry
impl Sync for AssetIdRegistry
impl Unpin for AssetIdRegistry
impl UnsafeUnpin for AssetIdRegistry
impl UnwindSafe for AssetIdRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more