1use crate::entity::{Entity, EntityId};
4use crate::hashing::IndexSet;
5use crate::prelude::Property;
6
7mod full_index;
8mod value_count_index;
9
10pub use full_index::*;
11pub use value_count_index::*;
12
13#[derive(Debug)]
14pub enum IndexSetResult<'a, E: Entity> {
15 Unsupported,
17 Empty,
19 Set(&'a IndexSet<EntityId<E>>),
21}
22
23#[derive(PartialEq, Eq, Debug)]
24pub enum IndexCountResult {
25 Unsupported,
27 Count(usize),
29}
30
31#[derive(Debug, Copy, Clone, PartialEq, Eq)]
32pub enum PropertyIndexType {
33 Unindexed,
34 FullIndex,
35 ValueCountIndex,
36}
37
38pub trait PropertyIndex<E: Entity, P: Property<E>> {
39 #[must_use]
40 fn index_type(&self) -> PropertyIndexType;
41
42 #[must_use]
43 fn get_index_set_result(&self, value: &P) -> IndexSetResult<'_, E>;
44
45 #[must_use]
46 fn get_index_count_result(&self, value: &P) -> IndexCountResult;
47
48 fn remove_entity(&mut self, value: &P, entity_id: EntityId<E>);
49
50 fn add_entity(&mut self, value: &P, entity_id: EntityId<E>);
51
52 #[must_use]
53 fn max_indexed(&self) -> usize;
54
55 fn set_max_indexed(&mut self, max_indexed: usize);
56}