Skip to main content

CrossTileSymbolIndex

Struct CrossTileSymbolIndex 

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

Cross-tile symbol index that deduplicates labels across tile boundaries.

This is the top-level entry point, keyed by style-layer id. Each style layer has an independent [LayerCrossTileIndex] so that labels from different layers do not interfere with each other.

§Usage

let mut index = CrossTileSymbolIndex::new();

// For each tile's symbol candidates:
let changed = index.assign("poi-labels", tile_id, instance_id, &mut entries);

// After placement, prune tiles no longer visible:
index.prune_stale("poi-labels", &active_instance_ids);

// When a tile is evicted from the cache:
index.remove_tile(&tile_id);

Implementations§

Source§

impl CrossTileSymbolIndex

Source

pub fn new() -> Self

Create an empty cross-tile symbol index.

Source

pub fn next_instance_id(&mut self) -> u64

Allocate a unique instance ID for a tile registration.

Each call to assign should use a fresh instance ID so the index can detect when a tile’s data has been replaced (e.g. after a style change or data update).

Source

pub fn assign( &mut self, layer_id: &str, tile_id: TileId, instance_id: u64, candidates: &mut [SymbolCandidateEntry], ) -> bool

Register a tile’s symbol candidates and assign cross-tile IDs.

After this call, each entry in candidates will have a non-zero assigned_cross_tile_id that is stable across zoom transitions and tile reloads.

Returns true if any IDs changed (caller should re-run placement).

Source

pub fn prune_stale( &mut self, layer_id: &str, current_instance_ids: &HashSet<u64>, ) -> bool

Remove grids for tiles whose instance IDs are no longer active.

Call this after each placement frame with the set of instance IDs that are still in use. Returns true if any stale grids were removed.

Source

pub fn remove_tile(&mut self, tile_id: &TileId)

Remove all index entries for a specific tile across all layers.

Call this when a tile is evicted from the tile cache to release the associated cross-tile IDs.

Source

pub fn prune_layers(&mut self, active_layers: &HashSet<String>)

Remove index state for layers that are no longer active.

active_layers is the set of style-layer IDs currently in use. Any layer not in this set has its index state dropped.

Source

pub fn tile_count(&self) -> usize

Total number of indexed tiles across all layers and zoom levels.

Source

pub fn entry_count(&self) -> usize

Total number of indexed symbol entries across all tiles and layers.

Trait Implementations§

Source§

impl Clone for CrossTileSymbolIndex

Source§

fn clone(&self) -> CrossTileSymbolIndex

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CrossTileSymbolIndex

Source§

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

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

impl Default for CrossTileSymbolIndex

Source§

fn default() -> CrossTileSymbolIndex

Returns the “default value” for a type. 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.