pub struct Snapshot {
pub entities: Vec<DynamicEntity>,
pub resources: Vec<Box<dyn Reflect>>,
/* private fields */
}Expand description
A collection of serializable entities and resources.
Can be serialized via SnapshotSerializer and deserialized via SnapshotDeserializer.
Fields§
§entities: Vec<DynamicEntity>Entities contained in the snapshot.
resources: Vec<Box<dyn Reflect>>Resources contained in the snapshot.
Implementations§
source§impl Snapshot
impl Snapshot
sourcepub fn from_world(world: &World) -> Self
pub fn from_world(world: &World) -> Self
Returns a complete Snapshot of the current [World] state.
Contains all saveable entities and resources, including Rollbacks.
Shortcut for
Snapshot::builder(world)
.extract_all_with_rollbacks()
.build();sourcepub fn builder(world: &World) -> SnapshotBuilder<'_>
pub fn builder(world: &World) -> SnapshotBuilder<'_>
Create a SnapshotBuilder from the [World], allowing you to create partial or filtered snapshots.
Example
Snapshot::builder(world)
// Extract all matching entities and resources
.extract_all()
// Clear all extracted entities without any components
.clear_empty()
// Build the `Snapshot`
.build();sourcepub fn applier<'a>(&'a self, world: &'a mut World) -> SnapshotApplier<'_>
pub fn applier<'a>(&'a self, world: &'a mut World) -> SnapshotApplier<'_>
Create a SnapshotApplier from the Snapshot and the [World].
This allows you to specify an entity map, hook, etc.
Example
let snapshot = Snapshot::from_world(world);
snapshot
.applier(world)
.hook(move |entity, cmds| {
// You can use the hook to add, get, or remove Components
if !entity.contains::<Parent>() {
cmds.set_parent(parent);
}
})
.apply();Trait Implementations§
source§impl CloneReflect for Snapshot
impl CloneReflect for Snapshot
source§fn clone_value(&self) -> Self
fn clone_value(&self) -> Self
Clone the value via Reflection.
Auto Trait Implementations§
impl !RefUnwindSafe for Snapshot
impl Send for Snapshot
impl Sync for Snapshot
impl Unpin for Snapshot
impl !UnwindSafe for Snapshot
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist.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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.