pub trait SpatialIndex: Send + Debug {
// Required methods
fn insert(&mut self, id: ItemId, bounds: Rect);
fn remove(&mut self, id: ItemId);
fn query(&self, scene_rect: Rect) -> Vec<ItemId>;
fn contains(&self, id: ItemId) -> bool;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Required Methods§
Sourcefn insert(&mut self, id: ItemId, bounds: Rect)
fn insert(&mut self, id: ItemId, bounds: Rect)
Insert or update an item’s bounds. Calling insert again with
the same id replaces the previous bounds (re-buckets the
item). Equivalent to remove(id); insert(id, bounds); on
implementations that need an explicit update path.
Sourcefn query(&self, scene_rect: Rect) -> Vec<ItemId>
fn query(&self, scene_rect: Rect) -> Vec<ItemId>
Items whose bounds intersect scene_rect, in implementation-
defined order. The result is deduplicated. May include false
positives (items in cells the rect overlaps but whose bounds
don’t actually intersect) — callers that need exact
intersection narrow with a per-item check.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".