Skip to main content

Station

Struct Station 

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

Station-local storage and metadata.

Implementations§

Source§

impl Station

Source

pub fn new(config: StationConfig) -> Self

Creates an empty station.

Source

pub const fn config(&self) -> StationConfig

Returns station configuration.

Source

pub const fn tick(&self) -> Tick

Current station tick.

Source

pub const fn owner_epoch(&self) -> OwnerEpoch

Current owner epoch.

Source

pub fn next_owner_epoch(&mut self) -> OwnerEpoch

Reserves and returns the next owner epoch for this station.

Source

pub fn len(&self) -> usize

Number of live entity records.

Source

pub fn is_empty(&self) -> bool

Returns whether the station has no entity records.

Source

pub fn advance_tick(&mut self)

Advances the authoritative station tick.

Source

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.

Source

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.

Source

pub fn get(&self, handle: EntityHandle) -> Option<&EntityRecord>

Gets an entity by handle if the generation is still valid.

Source

pub fn get_mut(&mut self, handle: EntityHandle) -> Option<&mut EntityRecord>

Gets a mutable entity record by handle.

Source

pub fn get_by_id(&self, id: EntityId) -> Option<&EntityRecord>

Gets an entity by stable id.

Source

pub fn get_by_id_mut(&mut self, id: EntityId) -> Option<&mut EntityRecord>

Gets a mutable entity record by stable id.

Source

pub fn handle_by_id(&self, id: EntityId) -> Option<EntityHandle>

Gets a station-local handle by stable id.

Source

pub fn move_owned( &mut self, handle: EntityHandle, position: Position3, ) -> Result<(), StationError>

Moves an authoritative entity and marks transform dirty.

Source

pub fn set_tags( &mut self, handle: EntityHandle, tags: EntityTags, ) -> Result<(), StationError>

Replaces authoritative entity tags and marks tags dirty.

Source

pub fn clear_dirty( &mut self, handle: EntityHandle, mask: DirtyMask, ) -> Result<(), StationError>

Clears selected dirty bits for a local entity record.

Source

pub fn iter(&self) -> impl Iterator<Item = &EntityRecord>

Iterates over live records.

Source

pub fn remove( &mut self, handle: EntityHandle, ) -> Result<EntityRecord, StationError>

Removes an entity record by handle.

Source

pub fn remove_by_id( &mut self, id: EntityId, ) -> Result<EntityRecord, StationError>

Removes an entity record by stable id.

Source

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.

Source

pub fn prewarm_handoff_ghost( &mut self, transfer: &HandoffTransfer, ) -> Result<EntityHandle, StationError>

Prewarms or refreshes a target-side ghost before owner commit.

Source

pub fn commit_incoming_handoff( &mut self, transfer: HandoffTransfer, ) -> Result<EntityHandle, StationError>

Commits the target side of an incoming handoff and becomes authoritative.

Source

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.

Source

pub fn snapshot(&self, version: SnapshotVersion) -> StationSnapshot

Exports an in-memory station snapshot.

Source

pub fn restore( config: StationConfig, snapshot: StationSnapshot, ) -> Result<Self, StationError>

Restores station state from a snapshot.

Trait Implementations§

Source§

impl Clone for Station

Source§

fn clone(&self) -> Station

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 Station

Source§

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

Formats the value using the given formatter. 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<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> 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.