bevy_trait_query/one/core/
fetch.rs1use std::{cell::UnsafeCell, panic::Location};
2
3use bevy_ecs::{
4 change_detection::MaybeLocation,
5 component::Tick,
6 ptr::{Ptr, ThinSlicePtr},
7 storage::{ComponentSparseSet, SparseSets},
8};
9
10use crate::TraitImplMeta;
11
12pub struct OneTraitFetch<'w, Trait: ?Sized> {
13 pub(crate) sparse_sets: &'w SparseSets,
17 pub(crate) storage: FetchStorage<'w, Trait>,
20 pub(crate) last_run: Tick,
21 pub(crate) this_run: Tick,
22}
23
24impl<Trait: ?Sized> Clone for OneTraitFetch<'_, Trait> {
25 fn clone(&self) -> Self {
26 *self
27 }
28}
29
30impl<Trait: ?Sized> Copy for OneTraitFetch<'_, Trait> {}
31
32pub(crate) enum FetchStorage<'w, Trait: ?Sized> {
33 Uninit,
34 Table {
35 column: Ptr<'w>,
40 added_ticks: ThinSlicePtr<'w, UnsafeCell<Tick>>,
41 changed_ticks: ThinSlicePtr<'w, UnsafeCell<Tick>>,
42 location: MaybeLocation<&'w UnsafeCell<&'static Location<'static>>>,
43 meta: TraitImplMeta<Trait>,
44 },
45 SparseSet {
46 components: &'w ComponentSparseSet,
50 meta: TraitImplMeta<Trait>,
51 },
52}
53
54impl<Trait: ?Sized> Clone for FetchStorage<'_, Trait> {
55 fn clone(&self) -> Self {
56 *self
57 }
58}
59impl<Trait: ?Sized> Copy for FetchStorage<'_, Trait> {}