Skip to main content

Access

Struct Access 

Source
pub struct Access { /* private fields */ }
Expand description

Describes the component access pattern for a query.

Used by the scheduler to determine which systems can run in parallel.

Implementations§

Source§

impl Access

Source

pub fn new() -> Self

Creates a new empty access descriptor.

Source

pub fn add_read(&mut self, id: ComponentId)

Adds a read access for the given component.

Source

pub fn add_write(&mut self, id: ComponentId)

Adds a write access for the given component.

Write access implies read access.

Source

pub fn reads(&self) -> impl Iterator<Item = &ComponentId>

Returns all components that are read (including those also written).

Source

pub fn writes(&self) -> &BTreeSet<ComponentId>

Returns all components that are written.

Source

pub fn reads_only(&self) -> impl Iterator<Item = &ComponentId>

Returns the set of read-only components (read but not written).

Source

pub fn conflicts_with(&self, other: &Access) -> bool

Checks if this access conflicts with another.

Two accesses conflict if:

  • One writes to a component that the other reads or writes
  • One writes to a resource that the other reads or writes
Source

pub fn is_read_only(&self) -> bool

Returns true if this access pattern is read-only.

This checks component, resource, and non-send resource access.

Source

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

Merges another access into this one.

Source

pub fn add_resource_read(&mut self, id: ResourceId)

Adds a read access for the given resource.

Source

pub fn add_resource_write(&mut self, id: ResourceId)

Adds a write access for the given resource.

Write access implies read access.

Source

pub fn resource_reads(&self) -> impl Iterator<Item = &ResourceId>

Returns all resources that are read (including those also written).

Source

pub fn resource_writes(&self) -> &BTreeSet<ResourceId>

Returns all resources that are written.

Source

pub fn resource_reads_only(&self) -> impl Iterator<Item = &ResourceId>

Returns the set of read-only resources (read but not written).

Source

pub fn resource_conflicts_with(&self, other: &Access) -> bool

Checks if resource access conflicts with another.

Two accesses conflict if one writes to a resource that the other reads or writes.

Source

pub fn has_resource_access(&self) -> bool

Checks if this access has any resource access.

Source

pub fn has_component_access(&self) -> bool

Checks if this access has any component access.

Source

pub fn add_non_send_read(&mut self, id: NonSendResourceId)

Adds a read access for the given non-send resource.

Source

pub fn add_non_send_write(&mut self, id: NonSendResourceId)

Adds a write access for the given non-send resource.

Write access implies read access.

Source

pub fn non_send_reads(&self) -> impl Iterator<Item = &NonSendResourceId>

Returns all non-send resources that are read (including those also written).

Source

pub fn non_send_writes(&self) -> &BTreeSet<NonSendResourceId>

Returns all non-send resources that are written.

Source

pub fn non_send_reads_only(&self) -> impl Iterator<Item = &NonSendResourceId>

Returns the set of read-only non-send resources (read but not written).

Source

pub fn non_send_conflicts_with(&self, other: &Access) -> bool

Checks if non-send resource access conflicts with another.

Two accesses conflict if one writes to a non-send resource that the other reads or writes.

Source

pub fn has_non_send_access(&self) -> bool

Checks if this access has any non-send resource access.

Source

pub fn requires_main_thread(&self) -> bool

Returns true if this access requires execution on the main thread.

This returns true if there is any non-send resource access.

Source

pub fn get_conflicts(&self, other: &Access) -> Option<AccessConflict>

Returns detailed information about conflicts between this access and another.

If there are no conflicts, returns None. Otherwise, returns an AccessConflict describing all the conflicting components and resources.

§Example
use goud_engine::ecs::query::Access;
use goud_engine::ecs::component::ComponentId;
use goud_engine::ecs::Component;

#[derive(Clone, Copy)]
struct Position { x: f32, y: f32 }
impl Component for Position {}

let mut access1 = Access::new();
access1.add_write(ComponentId::of::<Position>());

let mut access2 = Access::new();
access2.add_read(ComponentId::of::<Position>());

let conflict = access1.get_conflicts(&access2);
assert!(conflict.is_some());
let conflict = conflict.unwrap();
assert_eq!(conflict.component_conflicts().len(), 1);
Source

pub fn is_empty(&self) -> bool

Returns true if this access is empty (no reads or writes).

Source

pub fn clear(&mut self)

Clears all access information.

Trait Implementations§

Source§

impl Clone for Access

Source§

fn clone(&self) -> Access

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Access

Source§

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

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

impl Default for Access

Source§

fn default() -> Access

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

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

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

Source§

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

Source§

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