1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
mod sbox;
mod storage_id;
pub use storage_id::StorageId;
pub(crate) use sbox::SBox;
use crate::entity_id::EntityId;
use crate::memory_usage::StorageMemoryUsage;
use crate::sparse_set::SparseArray;
use alloc::borrow::Cow;
use core::any::Any;
pub trait SizedAny {
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
impl<T: 'static> SizedAny for T {
#[inline]
fn as_any(&self) -> &dyn Any {
self
}
#[inline]
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
}
pub trait Storage: SizedAny {
fn any(&self) -> &dyn Any {
SizedAny::as_any(self)
}
fn any_mut(&mut self) -> &mut dyn Any {
SizedAny::as_any_mut(self)
}
#[inline]
fn delete(&mut self, _entity: EntityId, _current: u32) {}
#[inline]
fn clear(&mut self, _current: u32) {}
fn memory_usage(&self) -> Option<StorageMemoryUsage> {
None
}
fn name(&self) -> Cow<'static, str> {
core::any::type_name::<Self>().into()
}
fn sparse_array(&self) -> Option<&SparseArray<EntityId, 32>> {
None
}
fn is_empty(&self) -> bool {
false
}
fn clear_all_removed_or_deleted(&mut self) {}
fn clear_all_removed_or_deleted_older_than_timestamp(
&mut self,
_timestamp: crate::TrackingTimestamp,
) {
}
}