pub struct ShapeTransitionTable { /* private fields */ }Expand description
Manages shape creation and transitions.
Thread-safety: This is NOT thread-safe. For multi-threaded use, wrap in a Mutex or use thread-local instances.
Implementations§
Source§impl ShapeTransitionTable
impl ShapeTransitionTable
Sourcepub fn get_shape(&self, id: ShapeId) -> &Shape
pub fn get_shape(&self, id: ShapeId) -> &Shape
Get a shape by its ID. Panics if the ID is invalid.
Sourcepub fn try_get_shape(&self, id: ShapeId) -> Option<&Shape>
pub fn try_get_shape(&self, id: ShapeId) -> Option<&Shape>
Get a shape by its ID, returning None if the ID is not present in
this table.
Use this when a ShapeId may have originated from a different
transition table (for example, a HashMapData::shape_id computed
under the process-default ambient handle but observed inside a
per-VM scope). In that case callers should degrade to the
hash-based slow path rather than panic on an out-of-range index.
Sourcepub fn transition(&mut self, from: ShapeId, property_name: u32) -> ShapeId
pub fn transition(&mut self, from: ShapeId, property_name: u32) -> ShapeId
Transition from from shape by adding property_name.
Returns the existing child shape if the transition already exists, otherwise creates a new shape with the property appended.
Sourcepub fn shape_for_keys(&mut self, keys: &[u32]) -> ShapeId
pub fn shape_for_keys(&mut self, keys: &[u32]) -> ShapeId
Build a shape by transitioning from root through all keys in order.
Sourcepub fn property_index(
&self,
shape_id: ShapeId,
property_name: u32,
) -> Option<usize>
pub fn property_index( &self, shape_id: ShapeId, property_name: u32, ) -> Option<usize>
Find the slot index of property_name in the given shape.
Returns None if the property is not part of this shape, or if
shape_id does not belong to this table (e.g. a stale ID carried
over from a different ambient handle — see try_get_shape).
O(n) scan of the shape’s properties list.
Sourcepub fn shape_count(&self) -> usize
pub fn shape_count(&self) -> usize
Total number of shapes in the table.