ExternalizedAnchorVariableSupply

Struct ExternalizedAnchorVariableSupply 

Source
pub struct ExternalizedAnchorVariableSupply<E, A>
where E: Eq + Hash + Clone + Send + Sync + 'static, A: Clone + Send + Sync + 'static,
{ /* private fields */ }
Expand description

Hash-based implementation of anchor variable supply.

Uses a HashMap internally for O(1) average-case lookups. Thread-safe via RwLock.

Implementations§

Source§

impl<E, A> ExternalizedAnchorVariableSupply<E, A>
where E: Eq + Hash + Clone + Send + Sync + 'static, A: Clone + Send + Sync + 'static,

Source

pub fn new(variable_name: impl Into<String>) -> Self

Creates a new externalized anchor variable supply.

Source

pub fn variable_name(&self) -> &str

Returns the variable name this supply tracks.

Source

pub fn cascade_anchor<I>(&self, entities: I, new_anchor: A)
where I: IntoIterator<Item = E>,

Updates anchors for all entities in a chain segment.

When an entity changes its chain position, all downstream entities in the chain need their anchor updated. This method cascades the update.

§Arguments
  • entities - Iterator of entities to update (in chain order)
  • new_anchor - The new anchor for all entities

Trait Implementations§

Source§

impl<E, A> AnchorVariableSupply<E, A> for ExternalizedAnchorVariableSupply<E, A>
where E: Eq + Hash + Clone + Send + Sync + 'static, A: Clone + Send + Sync + 'static,

Source§

fn get_anchor(&self, entity: &E) -> Option<A>

Gets the anchor for an entity. Read more
Source§

fn set_anchor(&self, entity: E, anchor: A)

Sets the anchor for an entity. Read more
Source§

fn remove(&self, entity: &E) -> Option<A>

Removes the anchor mapping for an entity.
Source§

fn clear(&self)

Clears all mappings.
Source§

fn len(&self) -> usize

Returns the number of tracked entities.
Source§

fn is_empty(&self) -> bool

Returns true if no entities are tracked.
Source§

impl<E, A> Debug for ExternalizedAnchorVariableSupply<E, A>
where E: Eq + Hash + Clone + Send + Sync + 'static, A: Clone + Send + Sync + 'static,

Source§

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

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

impl<E, A> Supply for ExternalizedAnchorVariableSupply<E, A>
where E: Eq + Hash + Clone + Send + Sync + 'static, A: Clone + Send + Sync + 'static,

Source§

fn supply_type_id(&self) -> TypeId

Returns the type ID of this supply for registration purposes.

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> 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, 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.