pub trait SpatialBackend: Send + Sync {
Show 17 methods
// Required methods
fn insert(&self, leaf: Leaf) -> SpatialResult<LeafId>;
fn remove(&self, id: LeafId) -> bool;
fn get(&self, id: LeafId) -> Option<Leaf>;
fn query_point(&self, p: Vec3) -> Vec<LeafId>;
fn query_aabb(&self, bb: Aabb) -> Vec<LeafId>;
fn query_sphere(&self, center: Vec3, radius: f32) -> Vec<LeafId>;
fn query_ray(&self, ray: Ray, max_t: f32) -> Vec<RayHit>;
fn query_frustum(&self, frustum: &Frustum) -> Vec<LeafId>;
fn query_knn(&self, p: Vec3, k: usize) -> Vec<LeafId>;
fn derive_branch(&self, meta: BranchMeta) -> SpatialResult<BranchId>;
fn branch_diff(
&self,
a: BranchId,
b: BranchId,
region: Aabb,
) -> Vec<DiffEntry>;
fn epoch(&self) -> u64;
fn len(&self) -> usize;
fn backend_name(&self) -> &str;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn max_leaves(&self) -> Option<usize> { ... }
fn insert_with_epoch(
&self,
leaf: Leaf,
parent_epoch: u64,
) -> SpatialResult<LeafId> { ... }
}Expand description
Unified spatial index backend interface (ADR-056 §8).
Implementations must be Send + Sync so they can be shared across
async tasks via Arc.
Required Methods§
Sourcefn insert(&self, leaf: Leaf) -> SpatialResult<LeafId>
fn insert(&self, leaf: Leaf) -> SpatialResult<LeafId>
Insert a leaf; returns the assigned id.
Sourcefn query_point(&self, p: Vec3) -> Vec<LeafId>
fn query_point(&self, p: Vec3) -> Vec<LeafId>
Leaves whose AABB contains p.
Sourcefn query_aabb(&self, bb: Aabb) -> Vec<LeafId>
fn query_aabb(&self, bb: Aabb) -> Vec<LeafId>
Leaves intersecting bb.
Sourcefn query_ray(&self, ray: Ray, max_t: f32) -> Vec<RayHit>
fn query_ray(&self, ray: Ray, max_t: f32) -> Vec<RayHit>
Leaves hit by ray (sorted by enter t).
Sourcefn query_frustum(&self, frustum: &Frustum) -> Vec<LeafId>
fn query_frustum(&self, frustum: &Frustum) -> Vec<LeafId>
Leaves intersecting a frustum.
Sourcefn query_knn(&self, p: Vec3, k: usize) -> Vec<LeafId>
fn query_knn(&self, p: Vec3, k: usize) -> Vec<LeafId>
k nearest leaves by AABB-center distance.
Sourcefn derive_branch(&self, meta: BranchMeta) -> SpatialResult<BranchId>
fn derive_branch(&self, meta: BranchMeta) -> SpatialResult<BranchId>
Derive a child branch (COW in Phase D; full clone in Phase C).
Sourcefn branch_diff(&self, a: BranchId, b: BranchId, region: Aabb) -> Vec<DiffEntry>
fn branch_diff(&self, a: BranchId, b: BranchId, region: Aabb) -> Vec<DiffEntry>
Presence-only branch diff inside region.
Sourcefn backend_name(&self) -> &str
fn backend_name(&self) -> &str
Human-readable backend name (e.g. "bvh").
Provided Methods§
Sourcefn max_leaves(&self) -> Option<usize>
fn max_leaves(&self) -> Option<usize>
Optional capacity limit.
Sourcefn insert_with_epoch(
&self,
leaf: Leaf,
parent_epoch: u64,
) -> SpatialResult<LeafId>
fn insert_with_epoch( &self, leaf: Leaf, parent_epoch: u64, ) -> SpatialResult<LeafId>
Insert only if store epoch matches parent_epoch.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".