Skip to main content

SpatialBackend

Trait SpatialBackend 

Source
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§

Source

fn insert(&self, leaf: Leaf) -> SpatialResult<LeafId>

Insert a leaf; returns the assigned id.

Source

fn remove(&self, id: LeafId) -> bool

Remove a leaf by id. Returns true if it was present.

Source

fn get(&self, id: LeafId) -> Option<Leaf>

Fetch a leaf by id.

Source

fn query_point(&self, p: Vec3) -> Vec<LeafId>

Leaves whose AABB contains p.

Source

fn query_aabb(&self, bb: Aabb) -> Vec<LeafId>

Leaves intersecting bb.

Source

fn query_sphere(&self, center: Vec3, radius: f32) -> Vec<LeafId>

Leaves intersecting sphere.

Source

fn query_ray(&self, ray: Ray, max_t: f32) -> Vec<RayHit>

Leaves hit by ray (sorted by enter t).

Source

fn query_frustum(&self, frustum: &Frustum) -> Vec<LeafId>

Leaves intersecting a frustum.

Source

fn query_knn(&self, p: Vec3, k: usize) -> Vec<LeafId>

k nearest leaves by AABB-center distance.

Source

fn derive_branch(&self, meta: BranchMeta) -> SpatialResult<BranchId>

Derive a child branch (COW in Phase D; full clone in Phase C).

Source

fn branch_diff(&self, a: BranchId, b: BranchId, region: Aabb) -> Vec<DiffEntry>

Presence-only branch diff inside region.

Source

fn epoch(&self) -> u64

Monotonic epoch (bumped on every mutation).

Source

fn len(&self) -> usize

Number of leaves on the active branch.

Source

fn backend_name(&self) -> &str

Human-readable backend name (e.g. "bvh").

Provided Methods§

Source

fn is_empty(&self) -> bool

True when the active branch has no leaves.

Source

fn max_leaves(&self) -> Option<usize>

Optional capacity limit.

Source

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

Implementors§