Skip to main content

StateTree

Struct StateTree 

Source
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

Source

pub fn at<P>(content: P) -> StateTree
where P: Into<PathBuf>,

A tree with every root at content.

Source

pub fn with_writable<P>(self, dir: P) -> StateTree
where P: Into<PathBuf>,

Move the runtime-writable state to dir, leaving the content where it is: a read-only install writes its saves and settings per-user.

Source

pub fn with_cache<P>(self, dir: P) -> StateTree
where P: Into<PathBuf>,

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.

Source

pub fn content_root(&self) -> &Path

The root holding what a build produces and reads.

Source

pub fn writable_root(&self) -> &Path

The root holding what the running application writes.

Source

pub fn assets_dir(&self) -> PathBuf

The state root’s assets/ directory.

Source

pub fn data_dir(&self) -> PathBuf

The state root’s data/ directory.

Source

pub fn worlds_dir(&self) -> PathBuf

The state root’s worlds/ directory.

Source

pub fn saves_dir(&self) -> PathBuf

Directory holding the runtime save files. Created on first write by the running application, never by a build.

Source

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.

Source

pub fn settings_path(&self) -> PathBuf

The mutable settings file, written by the in-engine settings menu and never by a build.

Source

pub fn crashes_dir(&self) -> PathBuf

Directory holding crash reports. Created on first write; capped by the writer’s retention pruning.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for StateTree

Source§

fn clone(&self) -> StateTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StateTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for StateTree

Source§

impl PartialEq for StateTree

Source§

fn eq(&self, other: &StateTree) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StateTree

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more