pub struct SnapshotBuilder<'a> { /* private fields */ }
Expand description
A snapshot builder that can extract entities, resources, and rollback Checkpoints
from a World
.
Implementations§
Source§impl<'a> SnapshotBuilder<'a>
impl<'a> SnapshotBuilder<'a>
Sourcepub fn snapshot(world: &'a World) -> Self
pub fn snapshot(world: &'a World) -> Self
Create a new SnapshotBuilder
from the World
.
You must call at least one of the extract
methods or the built snapshot will be empty.
§Example
SnapshotBuilder::snapshot(world)
// Extract all matching entities and resources
.extract_all()
// Clear all extracted entities without any components
.clear_empty()
// Build the `Snapshot`
.build();
Sourcepub fn checkpoint(world: &'a World) -> Self
pub fn checkpoint(world: &'a World) -> Self
Create a new SnapshotBuilder
from the World
.
Types extracted by this builder will respect the CheckpointRegistry
.
You must call at least one of the extract
methods or the built snapshot will be empty.
§Example
SnapshotBuilder::checkpoint(world)
// Extract all matching entities and resources
.extract_all()
// Clear all extracted entities without any components
.clear_empty()
// Build the `Snapshot`
.build();
Source§impl<'a> SnapshotBuilder<'a>
impl<'a> SnapshotBuilder<'a>
Sourcepub fn world<'w>(&self) -> &'w Worldwhere
'a: 'w,
pub fn world<'w>(&self) -> &'w Worldwhere
'a: 'w,
Retrieve the builder’s reference to the World
.
Sourcepub fn type_registry(self, type_registry: &'a TypeRegistry) -> Self
pub fn type_registry(self, type_registry: &'a TypeRegistry) -> Self
Set the TypeRegistry
to be used for reflection.
If this is not provided, the AppTypeRegistry
resource is used as a default.
Source§impl SnapshotBuilder<'_>
impl SnapshotBuilder<'_>
Sourcepub fn filter(self, filter: SceneFilter) -> Self
pub fn filter(self, filter: SceneFilter) -> Self
Specify a custom SceneFilter
to be used with this builder.
This filter is applied to both components and resources.
Sourcepub fn allow<T: Any>(self) -> Self
pub fn allow<T: Any>(self) -> Self
Allows the given type, T
, to be included in the generated snapshot.
This method may be called multiple times for any number of types.
This is the inverse of deny
.
If T
has already been denied, then it will be removed from the blacklist.
Sourcepub fn deny<T: Any>(self) -> Self
pub fn deny<T: Any>(self) -> Self
Denies the given type, T
, from being included in the generated snapshot.
This method may be called multiple times for any number of types.
This is the inverse of allow
.
If T
has already been allowed, then it will be removed from the whitelist.
Source§impl SnapshotBuilder<'_>
impl SnapshotBuilder<'_>
Sourcepub fn extract_entity(self, entity: Entity) -> Self
pub fn extract_entity(self, entity: Entity) -> Self
Extract a single entity from the builder’s World
.
Sourcepub fn extract_entities(self, entities: impl Iterator<Item = Entity>) -> Self
pub fn extract_entities(self, entities: impl Iterator<Item = Entity>) -> Self
Extract the given entities from the builder’s World
.
§Panics
If type_registry
is not set or the AppTypeRegistry
resource does not exist.
Sourcepub fn extract_entities_matching<F: Fn(&EntityRef<'_>) -> bool>(
self,
filter: F,
) -> Self
pub fn extract_entities_matching<F: Fn(&EntityRef<'_>) -> bool>( self, filter: F, ) -> Self
Extract the entities matching the given filter from the builder’s World
.
Sourcepub fn extract_all_entities(self) -> Self
pub fn extract_all_entities(self) -> Self
Extract all entities from the builder’s World
.
Sourcepub fn extract_entities_manual<F, B>(self, func: F) -> Self
pub fn extract_entities_manual<F, B>(self, func: F) -> Self
Extract all entities with a custom extraction function.
Sourcepub fn extract_prefab<F, P>(self, func: F) -> Self
pub fn extract_prefab<F, P>(self, func: F) -> Self
Extract all Prefab
entities with a custom extraction function.
Sourcepub fn extract_all_prefabs<P: Prefab>(self) -> Self
pub fn extract_all_prefabs<P: Prefab>(self) -> Self
Sourcepub fn extract_resource<T: Resource>(self) -> Self
pub fn extract_resource<T: Resource>(self) -> Self
Extract a single resource from the builder’s World
.
Sourcepub fn extract_resource_by_path<T: AsRef<str>>(self, type_path: T) -> Self
pub fn extract_resource_by_path<T: AsRef<str>>(self, type_path: T) -> Self
Extract a single resource with the given type path from the builder’s World
.
Sourcepub fn extract_resources_by_path<T: AsRef<str>>(
self,
type_paths: impl Iterator<Item = T>,
) -> Self
pub fn extract_resources_by_path<T: AsRef<str>>( self, type_paths: impl Iterator<Item = T>, ) -> Self
Extract resources with the given type paths from the builder’s World
.
§Panics
If type_registry
is not set or the AppTypeRegistry
resource does not exist.
Sourcepub fn extract_resources_by_type_id(
self,
type_ids: impl Iterator<Item = TypeId>,
) -> Self
pub fn extract_resources_by_type_id( self, type_ids: impl Iterator<Item = TypeId>, ) -> Self
Extract resources with the given TypeId
’s from the builder’s World
.
§Panics
If type_registry
is not set or the AppTypeRegistry
resource does not exist.
Sourcepub fn extract_all_resources(self) -> Self
pub fn extract_all_resources(self) -> Self
Extract all resources from the builder’s World
.
Sourcepub fn extract_checkpoints(self) -> Self
pub fn extract_checkpoints(self) -> Self
Extract Checkpoints
from the builder’s World
.
§Panics
If type_registry
is not set or the AppTypeRegistry
resource does not exist.
Sourcepub fn extract_all(self) -> Self
pub fn extract_all(self) -> Self
Extract all entities, and resources from the builder’s World
.
Sourcepub fn extract_all_with_checkpoints(self) -> Self
pub fn extract_all_with_checkpoints(self) -> Self
Extract all entities, resources, and Checkpoints
from the builder’s World
.
Source§impl SnapshotBuilder<'_>
impl SnapshotBuilder<'_>
Sourcepub fn clear_entities(self) -> Self
pub fn clear_entities(self) -> Self
Clear all extracted entities.
Sourcepub fn clear_resources(self) -> Self
pub fn clear_resources(self) -> Self
Clear all extracted resources.
Sourcepub fn clear_empty(self) -> Self
pub fn clear_empty(self) -> Self
Clear all extracted entities without any components.
Sourcepub fn clear_checkpoints(self) -> Self
pub fn clear_checkpoints(self) -> Self
Clear Checkpoints
from the snapshot.
Auto Trait Implementations§
impl<'a> Freeze for SnapshotBuilder<'a>
impl<'a> !RefUnwindSafe for SnapshotBuilder<'a>
impl<'a> Send for SnapshotBuilder<'a>
impl<'a> Sync for SnapshotBuilder<'a>
impl<'a> Unpin for SnapshotBuilder<'a>
impl<'a> !UnwindSafe for SnapshotBuilder<'a>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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