pub struct StateTree { /* private fields */ }Expand description
Where a project’s state lives, and what hangs off it.
Built by whatever runs the process – the dev CLI from its project directory, a shipped application from the directory beside its executable, an embedder from whatever its own layout implies – and passed down. Library code is handed one; it never resolves a root for itself.
Three roots, because the three fall apart on real installs:
- the content root holds what a build produces and reads (
data/,assets/,worlds/), - the writable root holds what the running application writes
(
saves/,settings,crashes/), split away when the content root is a read-only install such as Program Files, - the cache root holds the regenerable segments, split away when the caches should outlive (or be shared across) the content beside them.
An unsplit tree resolves all three at the content root, which is the single-folder layout a portable install and a dev checkout both use.
Implementations§
Source§impl StateTree
impl StateTree
Sourcepub fn with_writable<P>(self, dir: P) -> StateTree
pub fn with_writable<P>(self, dir: P) -> StateTree
Move the runtime-writable state to dir, leaving the content where it
is: a read-only install writes its saves and settings per-user.
Sourcepub fn with_cache<P>(self, dir: P) -> StateTree
pub fn with_cache<P>(self, dir: P) -> StateTree
Move both cache segments to dir. Anchors the regenerable artifacts
away from the content and the writable state, so a warm cache can sit
behind a content root that is read-only, or freshly built, or both.
Sourcepub fn content_root(&self) -> &Path
pub fn content_root(&self) -> &Path
The root holding what a build produces and reads.
Sourcepub fn writable_root(&self) -> &Path
pub fn writable_root(&self) -> &Path
The root holding what the running application writes.
Sourcepub fn assets_dir(&self) -> PathBuf
pub fn assets_dir(&self) -> PathBuf
The state root’s assets/ directory.
Sourcepub fn worlds_dir(&self) -> PathBuf
pub fn worlds_dir(&self) -> PathBuf
The state root’s worlds/ directory.
Sourcepub fn saves_dir(&self) -> PathBuf
pub fn saves_dir(&self) -> PathBuf
Directory holding the runtime save files. Created on first write by the running application, never by a build.
Sourcepub fn preview_saves_dir(&self) -> PathBuf
pub fn preview_saves_dir(&self) -> PathBuf
Sandboxed sibling of saves_dir for preview
sessions: the save UI keeps working against this directory, the real
saves are never touched, and the sandbox is wiped at each session start.
Sourcepub fn settings_path(&self) -> PathBuf
pub fn settings_path(&self) -> PathBuf
The mutable settings file, written by the in-engine settings menu and never by a build.
Sourcepub fn crashes_dir(&self) -> PathBuf
pub fn crashes_dir(&self) -> PathBuf
Directory holding crash reports. Created on first write; capped by the writer’s retention pruning.
Sourcepub fn editor_session_path(&self) -> PathBuf
pub fn editor_session_path(&self) -> PathBuf
The editor’s session store: the per-project state an editor run carries between launches, which is state rather than cache.
Sourcepub fn runtime_cache_path(&self) -> PathBuf
pub fn runtime_cache_path(&self) -> PathBuf
The segment a running application writes: one container holding every regenerable artifact it produces for its own later launches, indexed by producer and key.
Deletable at any time; whatever is missing is recomputed. The application writes this file and no other, so a concurrent build writing a segment of its own never shares a file with it.
Sourcepub fn bundled_runtime_cache_path(&self) -> PathBuf
pub fn bundled_runtime_cache_path(&self) -> PathBuf
The runtime segment a bundle ships, read-only. cn export warms it with
the shader binaries a first launch would otherwise compile; because those
artifacts are backend IR (DXBC / SPIR-V) rather than machine code, one
warmed at package time is valid on any machine.
Always resolves against the content root, so it stays readable on a
read-only install. That is also the only thing separating it from
runtime_cache_path: a bundle the player
can write to has one segment serving both roles.
Sourcepub fn build_cache_path(&self) -> PathBuf
pub fn build_cache_path(&self) -> PathBuf
The segment a build writes: one container holding every payload, expansion, and baked thumbnail a cook produced, indexed by producer and key.
Deletable at any time; whatever is missing is recompiled.
Trait Implementations§
impl Eq for StateTree
impl StructuralPartialEq for StateTree
Auto Trait Implementations§
impl Freeze for StateTree
impl RefUnwindSafe for StateTree
impl Send for StateTree
impl Sync for StateTree
impl Unpin for StateTree
impl UnsafeUnpin for StateTree
impl UnwindSafe for StateTree
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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