Expand description
The ledger of who holds a component.
Component values live in UnsafeCells, so the compiler cannot police
aliasing between two access paths, and this ledger does. A claim is
registered before any reference to a value is handed out and is released when
the holder goes away; a claim that overlaps one already held panics, naming
both sites. Nothing else checks aliasing at run time.
A claim covers either every row of one archetype, which is what a query over a scope asks for, or one row, which is what a single-entity lookup asks for. Two claims conflict when they name the same component type, at least one of them writes, and they can reach the same row: two single-row claims when they name the same entity, anything else when they name the same archetype.
The archetype granularity is deliberately conservative. A query cannot tell before iterating which rows of a mixed archetype a scope can see, so it claims the whole archetype; a single-entity claim on a row of that archetype is then refused even when the query would not have reached that row. Refusing a pair that would have been fine is the price of never allowing a pair that is not.
Claims are filed under the holder that made them rather than under individual ids, so a holder carries one word of ledger state and releases in one pass.
What a holder claims is what it asked a crate::PlanBuilder for: there is
no separate declaration of reached components, so a query cannot claim less
than it reads.
Re-exportsΒ§
use core::any::TypeId;πuse core::panic::Location;πuse crate::entity::Entity;πuse crate::query::Ask;πuse crate::query::Mode;πuse crate::world::World;π
StructsΒ§
- Borrow
Ledger π - Every claim currently held on a worldβs components.
- Claims π
- The claims one holder owns, released together when it is dropped.
- Lease π
- One registered claim.
EnumsΒ§
- Rows π
- Which rows a claim covers.
FunctionsΒ§
- claim_
archetype π - Claim on
archetypeevery component the asks named, shared or exclusive. - claim_
row π - Claim on one entityβs row every component the asks named.