pub struct Station { /* private fields */ }Expand description
Station-local storage and metadata.
Implementations§
Source§impl Station
impl Station
Sourcepub fn new(config: StationConfig) -> Self
pub fn new(config: StationConfig) -> Self
Creates an empty station.
Sourcepub fn with_capacity(config: StationConfig, entity_capacity: usize) -> Self
pub fn with_capacity(config: StationConfig, entity_capacity: usize) -> Self
Creates an empty station with capacity for local entity records.
Sourcepub fn reserve_entities(&mut self, additional: usize)
pub fn reserve_entities(&mut self, additional: usize)
Reserves capacity for at least additional more local entities.
Sourcepub fn reserve_free_handles(&mut self, additional: usize)
pub fn reserve_free_handles(&mut self, additional: usize)
Reserves recycled-handle slots for caller-expected despawn churn.
Sourcepub fn reclaim_retained_capacity(&mut self)
pub fn reclaim_retained_capacity(&mut self)
Releases unused retained storage without changing live handles.
Sourcepub fn entity_capacity(&self) -> usize
pub fn entity_capacity(&self) -> usize
Entity record slots currently retained without another allocation.
Sourcepub fn id_index_capacity(&self) -> usize
pub fn id_index_capacity(&self) -> usize
Entity-id lookup entries currently retained without another rehash.
Sourcepub fn free_list_capacity(&self) -> usize
pub fn free_list_capacity(&self) -> usize
Recycled handle indexes currently retained without another allocation.
Sourcepub const fn config(&self) -> StationConfig
pub const fn config(&self) -> StationConfig
Returns station configuration.
Sourcepub const fn owner_epoch(&self) -> OwnerEpoch
pub const fn owner_epoch(&self) -> OwnerEpoch
Current owner epoch.
Sourcepub fn next_owner_epoch(&mut self) -> OwnerEpoch
pub fn next_owner_epoch(&mut self) -> OwnerEpoch
Reserves and returns the next owner epoch for this station.
Sourcepub fn advance_tick(&mut self)
pub fn advance_tick(&mut self)
Advances the authoritative station tick.
Sourcepub fn spawn_owned(
&mut self,
id: EntityId,
position: Position3,
bounds: Bounds,
policy_id: PolicyId,
) -> Result<EntityHandle, StationError>
pub fn spawn_owned( &mut self, id: EntityId, position: Position3, bounds: Bounds, policy_id: PolicyId, ) -> Result<EntityHandle, StationError>
Spawns an authoritative entity in this station.
Sourcepub fn upsert_ghost(
&mut self,
id: EntityId,
position: Position3,
bounds: Bounds,
policy_id: PolicyId,
owner_station: StationId,
owner_epoch: OwnerEpoch,
expires_at: Tick,
) -> EntityHandle
pub fn upsert_ghost( &mut self, id: EntityId, position: Position3, bounds: Bounds, policy_id: PolicyId, owner_station: StationId, owner_epoch: OwnerEpoch, expires_at: Tick, ) -> EntityHandle
Inserts or refreshes a read-only ghost entity.
Sourcepub fn get(&self, handle: EntityHandle) -> Option<&EntityRecord>
pub fn get(&self, handle: EntityHandle) -> Option<&EntityRecord>
Gets an entity by handle if the generation is still valid.
Sourcepub fn get_mut(&mut self, handle: EntityHandle) -> Option<&mut EntityRecord>
pub fn get_mut(&mut self, handle: EntityHandle) -> Option<&mut EntityRecord>
Gets a mutable entity record by handle.
Sourcepub fn get_by_id(&self, id: EntityId) -> Option<&EntityRecord>
pub fn get_by_id(&self, id: EntityId) -> Option<&EntityRecord>
Gets an entity by stable id.
Sourcepub fn get_by_id_mut(&mut self, id: EntityId) -> Option<&mut EntityRecord>
pub fn get_by_id_mut(&mut self, id: EntityId) -> Option<&mut EntityRecord>
Gets a mutable entity record by stable id.
Sourcepub fn handle_by_id(&self, id: EntityId) -> Option<EntityHandle>
pub fn handle_by_id(&self, id: EntityId) -> Option<EntityHandle>
Gets a station-local handle by stable id.
Sourcepub fn move_owned(
&mut self,
handle: EntityHandle,
position: Position3,
) -> Result<(), StationError>
pub fn move_owned( &mut self, handle: EntityHandle, position: Position3, ) -> Result<(), StationError>
Moves an authoritative entity and marks transform dirty.
Replaces authoritative entity tags and marks tags dirty.
Sourcepub fn clear_dirty(
&mut self,
handle: EntityHandle,
mask: DirtyMask,
) -> Result<(), StationError>
pub fn clear_dirty( &mut self, handle: EntityHandle, mask: DirtyMask, ) -> Result<(), StationError>
Clears selected dirty bits for a local entity record.
Sourcepub fn iter(&self) -> impl Iterator<Item = &EntityRecord>
pub fn iter(&self) -> impl Iterator<Item = &EntityRecord>
Iterates over live records.
Sourcepub fn remove(
&mut self,
handle: EntityHandle,
) -> Result<EntityRecord, StationError>
pub fn remove( &mut self, handle: EntityHandle, ) -> Result<EntityRecord, StationError>
Removes an entity record by handle.
Sourcepub fn remove_by_id(
&mut self,
id: EntityId,
) -> Result<EntityRecord, StationError>
pub fn remove_by_id( &mut self, id: EntityId, ) -> Result<EntityRecord, StationError>
Removes an entity record by stable id.
Sourcepub fn prepare_outgoing_handoff(
&self,
entity_id: EntityId,
target_station: StationId,
target_owner_epoch: OwnerEpoch,
source_ghost_expires_at: Tick,
) -> Result<HandoffTransfer, StationError>
pub fn prepare_outgoing_handoff( &self, entity_id: EntityId, target_station: StationId, target_owner_epoch: OwnerEpoch, source_ghost_expires_at: Tick, ) -> Result<HandoffTransfer, StationError>
Prepares an outgoing handoff transfer without mutating ownership yet.
Sourcepub fn prewarm_handoff_ghost(
&mut self,
transfer: &HandoffTransfer,
) -> Result<EntityHandle, StationError>
pub fn prewarm_handoff_ghost( &mut self, transfer: &HandoffTransfer, ) -> Result<EntityHandle, StationError>
Prewarms or refreshes a target-side ghost before owner commit.
Sourcepub fn commit_incoming_handoff(
&mut self,
transfer: HandoffTransfer,
) -> Result<EntityHandle, StationError>
pub fn commit_incoming_handoff( &mut self, transfer: HandoffTransfer, ) -> Result<EntityHandle, StationError>
Commits the target side of an incoming handoff and becomes authoritative.
Sourcepub fn commit_outgoing_handoff(
&mut self,
transfer: &HandoffTransfer,
) -> Result<EntityHandle, StationError>
pub fn commit_outgoing_handoff( &mut self, transfer: &HandoffTransfer, ) -> Result<EntityHandle, StationError>
Commits the source side of an outgoing handoff and keeps a short-lived ghost.
Sourcepub fn snapshot(&self, version: SnapshotVersion) -> StationSnapshot
pub fn snapshot(&self, version: SnapshotVersion) -> StationSnapshot
Exports an in-memory station snapshot.
Sourcepub fn snapshot_into(
&self,
version: SnapshotVersion,
snapshot: &mut StationSnapshot,
)
pub fn snapshot_into( &self, version: SnapshotVersion, snapshot: &mut StationSnapshot, )
Exports an in-memory snapshot into caller-owned reusable storage.
Sourcepub fn restore(
config: StationConfig,
snapshot: StationSnapshot,
) -> Result<Self, StationError>
pub fn restore( config: StationConfig, snapshot: StationSnapshot, ) -> Result<Self, StationError>
Restores station state from a snapshot.
Sourcepub fn restore_tracked(
config: StationConfig,
snapshot: StationSnapshot,
) -> Result<(Self, StationRestoreStats), StationError>
pub fn restore_tracked( config: StationConfig, snapshot: StationSnapshot, ) -> Result<(Self, StationRestoreStats), StationError>
Restores station state and reports capacity behavior during insertion.