Skip to main content

SystemAccess

Enum SystemAccess 

Source
pub enum SystemAccess {
    None,
    Shared(FilteredAccessSet),
    Exclusive,
}
Expand description

Represents the access a System requires to the World.

Variants§

§

None

The system does not access the world at all.

§

Shared(FilteredAccessSet)

The system requires shared access to the world, which means it can run in parallel with other systems that also require shared access, as long as they don’t require exclusive access to the same components.

§

Exclusive

The system requires exclusive access to the world, meaning no other Shared or Exclusive system can run in parallel with it.

Implementations§

Source§

impl SystemAccess

Source

pub fn is_none(&self) -> bool

Returns true if the system does not access the world at all, so it can run in parallel with any other system.

Source

pub fn is_shared(&self) -> bool

Returns true if the system requires shared access to the world, which means it can run in parallel with other systems that also require shared access, as long as they don’t require exclusive access to the same components.

Source

pub fn is_exclusive(&self) -> bool

Returns true if the system requires exclusive access to the world.

Source

pub fn is_compatible(&self, other: &Self) -> bool

Returns true if this system’s access is compatible with the other system’s access, such that they can run in parallel without conflicting with each other.

Source

pub fn get_conflicts_single( &self, filtered_access: &FilteredAccess, ) -> AccessConflicts

Returns the conflicts between the system’s current access and the provided access.

  • If the system currently has None access, it will return an empty AccessConflicts (i.e. no conflicts).
  • If the system currently has Shared access, the conflicts between individual components or resources will be returned.
  • If the system currently has Exclusive access, it will return AccessConflicts::All.
Source

pub fn get_conflicts(&self, other: &Self) -> AccessConflicts

Returns the conflicts between the system’s current access and another system’s access.

  • If either system has None access, it will return an empty AccessConflicts (i.e. no conflicts).
  • If both systems have Shared access, the conflicts between individual components or resources will be returned.
  • If either system has Exclusive access, it will return AccessConflicts::All.
Source

pub fn to_filtered_access_set(&self) -> Cow<'_, FilteredAccessSet>

Converts the system’s current access into a FilteredAccessSet.

Source

pub fn require_shared_access<T>( &mut self, system_meta: &SystemMeta, ) -> &mut FilteredAccessSet

Marks the system as requiring shared access to the world, which means it can run in parallel with other systems that also require shared access, as long as they don’t require exclusive access to the same components.

The provided type T is used for error reporting in case of access conflicts; it should be the type of the system parameter that is requesting shared access.

§Panics

If the system already has exclusive access, this method will panic with an error message indicating the conflict.

§Examples
§Only metadata access required

If a system parameter requires access to world metadata but not any particular components, you may call this function without modifying the returned FilteredAccessSet:

pub struct MyWorldId(WorldId);

// SAFETY: World metadata is registered and accessed.
unsafe impl SystemParam for MyWorldId {
    type State = ();
    type Item<'world, 'state> = MyWorldId;

    fn init_state(_: &mut World) -> Self::State {}

    fn init_access(
        _state: &Self::State,
        system_meta: &mut SystemMeta,
        system_access: &mut SystemAccess,
        _world: &mut World,
    ) {
        system_access.require_shared_access::<Self>(system_meta);
    }

    unsafe fn get_param<'world, 'state>(
        _: &'state mut Self::State,
        _: &SystemMeta,
        world: UnsafeWorldCell<'world>,
        _: Tick,
    ) -> Result<Self::Item<'world, 'state>, SystemParamValidationError> {
        Ok(MyWorldId(world.id()))
    }
}
Source

pub fn require_exclusive_access<T>(&mut self, system_meta: &SystemMeta)

Marks the system as requiring exclusive access to the world, meaning no other Shared or Exclusive system can run in parallel with it.

The provided type T is used for error reporting in case of access conflicts; it should be the type of the system parameter that is requesting exclusive access.

§Panics

If the system already has shared or exclusive access, this method will panic with an error message indicating the conflict.

Source

pub fn try_add( &mut self, filtered_access: FilteredAccess, ) -> Result<(), AccessConflicts>

Attempts to add the provided FilteredAccess to the system’s current access.

§Errors

If there are conflicts with the system’s current access, an AccessConflicts error will be returned.

Source

pub fn ensure_filtered_access(&mut self, filtered_access: FilteredAccess)

Marks the system as requiring access to certain or all components or resources in the World.

Source

pub fn ensure_metadata_access(&mut self)

Marks the system as requiring access to World metadata (e.g. Archetypes, Components, etc.).

Source

pub fn extend(&mut self, other: Self)

Merges the provided SystemAccess into the system’s current access.

Trait Implementations§

Source§

impl Clone for SystemAccess

Source§

fn clone(&self) -> SystemAccess

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SystemAccess

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SystemAccess

Source§

fn default() -> SystemAccess

Returns the “default value” for a type. Read more
Source§

impl Eq for SystemAccess

Source§

impl PartialEq for SystemAccess

Source§

fn eq(&self, other: &SystemAccess) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SystemAccess

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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

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

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynEq for T
where T: Any + Eq,

Source§

fn dyn_eq(&self, other: &(dyn DynEq + 'static)) -> bool

This method tests for self and other values to be equal. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

Source§

type Template = T

The Template for this type.
Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

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

Source§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
Source§

impl<A> Is for A
where A: Any,

Source§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
Source§

impl<T> Template for T
where T: Clone + Unpin,

Source§

type Output = T

The type of value produced by this Template.
Source§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a Template::Output.
Source§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of self.