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§

source§

impl<'w> RestrictedWorldView<'w>

Fundamental methods for working with a RestrictedWorldView

source

pub fn new(world: &'w mut World) -> RestrictedWorldView<'w>

Create a new RestrictedWorldView with permission to access everything.

source

pub fn resources_components( world: &'w mut World ) -> (RestrictedWorldView<'w>, RestrictedWorldView<'w>)

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

source

pub fn world(&self) -> UnsafeWorldCell<'w>

source

pub fn allows_access_to_resource(&self, type_id: TypeId) -> bool

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

source

pub fn allows_access_to_component(&self, component: (Entity, TypeId)) -> bool

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

source

pub fn split_off_resource( &mut self, resource: TypeId ) -> (RestrictedWorldView<'_>, RestrictedWorldView<'_>)

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

source

pub fn split_off_resource_typed<R: Resource>( self ) -> Option<(Mut<'w, R>, RestrictedWorldView<'w>)>

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

source

pub fn split_off_component( &mut self, component: (Entity, TypeId) ) -> (RestrictedWorldView<'_>, RestrictedWorldView<'_>)

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).

source

pub fn split_off_components( &mut self, components: impl Iterator<Item = (Entity, TypeId)> + Copy ) -> (RestrictedWorldView<'_>, RestrictedWorldView<'_>)

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

source§

impl<'w> RestrictedWorldView<'w>

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

source

pub fn contains_entity(&self, entity: Entity) -> bool

source

pub fn get_resource_mut<R: Resource>(&mut self) -> Result<Mut<'_, R>, Error>

Gets a mutable reference to the resource of the given type

source

pub fn get_two_resources_mut<R1: Resource, R2: Resource>( &mut self ) -> (Result<Mut<'_, R1>, Error>, Result<Mut<'_, R2>, Error>)

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

source

pub fn get_resource_reflect_mut_by_id( &mut self, type_id: TypeId, type_registry: &TypeRegistry ) -> Result<(&mut dyn Reflect, impl FnOnce() + '_), Error>

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.

source

pub fn get_entity_component_reflect( &mut self, entity: Entity, component: TypeId, type_registry: &TypeRegistry ) -> Result<(&mut dyn Reflect, bool, impl FnOnce() + '_), Error>

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§

source§

impl<'a> From<&'a mut World> for RestrictedWorldView<'a>

source§

fn from(value: &'a mut World) -> Self

Converts to this type from the input type.

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

source§

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> 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<T> Downcast<T> for T

source§

fn downcast(&self) -> &T

source§

impl<T> Downcast for T
where T: Any,

source§

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.
source§

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.
source§

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.
source§

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.
source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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>,

§

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> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

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
source§

impl<T> Settings for T
where T: 'static + Send + Sync,

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,