pub trait SaveWorld {
// Required methods
fn save(self, path: impl Into<PathBuf>);
fn dump(self, path: impl Into<PathBuf>);
}
Expand description
Trait used to save a World
to a file.
Required Methods§
Sourcefn save(self, path: impl Into<PathBuf>)
fn save(self, path: impl Into<PathBuf>)
Inserts a new Request::Save
with the given path
into this World
.
This request is processed during SaveStage::Save
. During this stage, any Entity
with a Save
Component
is serialized into a DynamicScene
which is then written
into a file located at given path
.
If the save request fails, an error
message will be logged with cause of failure.
Sourcefn dump(self, path: impl Into<PathBuf>)
fn dump(self, path: impl Into<PathBuf>)
Inserts a new Request::Save
with the given path
into this World
.
This request is processed during SaveStage::Save
. During this stage, all entities
are serialized into a DynamicScene
which is then written into a file located at given path
.
Unlike SaveWorld::save()
, this function saves all entities and their serializable components.
The resulting file should not be used for loading, as it most likely has more data than required to
actually load the game, which may result in duplicate or conflicting entities.
As a result, this function should be used primarily for diagnostics, as it can be useful for inspecting worlds in a very simple, and somewhat readable text format.
If the dump request fails, an error
message will be logged with cause of failure.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.