pub struct RestrictedWorldView<'w> { /* private fields */ }
Expand description

A view into the world which may only access certain resources and components. A restricted form of &mut World.

Can be used to access a value, and give out the remaining “&mut World” somewhere else.

Example usage

use bevy_ecs::prelude::*;
use std::any::TypeId;
use bevy_inspector_egui::restricted_world_view::RestrictedWorldView;

let mut world = World::new();
let mut world = RestrictedWorldView::new(&mut world);

let (mut materials, world) = world.split_off_resource(TypeId::of::<Assets<StandardMaterial>>());
let materials = materials.get_resource_mut::<Assets<StandardMaterial>>();

pass_somewhere_else(world);

Implementations§

Fundamental methods for working with a RestrictedWorldView

Create a new RestrictedWorldView with permission to access everything.

Splits the world into one view which may only be used for resource access, and another which may only be used for component access.

Whether the resource with the given TypeId may be accessed from this world view

Whether the given component at the entity may be accessed from this world view

Splits this view into one view that only has access the the resource resource (.0), and the rest (.1).

Like RestrictedWorldView::split_off_resource, but takes self and returns 'w lifetimes.

Splits this view into one view that only has access the the component component.1 at the entity component.0 (.0), and the rest (.1).

Splits this view into one view that only has access the the component-entity pairs components (.0), and the rest (.1)

Some safe methods for getting values out of the RestrictedWorldView. Also has some methods for getting values in their Reflect form.

Gets a mutable reference to the resource of the given type

Gets mutable reference to two resources. Panics if R1 = R2.

Gets a mutable reference in form of a &mut dyn Reflect to the resource given by type_id.

Returns an error if the type does not register Reflect.

Also returns a impl FnOnce() to mark the value as changed.

Gets a mutable reference in form of a &mut dyn Reflect to a component at an entity.

Returns an error if the type does not register Reflect.

Also returns a impl FnOnce() to mark the value as changed.

Trait Implementations§

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Return the T [ShaderType] for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
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.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.

Returns the argument unchanged.

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

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more