1use crate::assets::storage::RawAssetHandle;
2
3pub struct Handle<T> {
8 pub id: RawAssetHandle,
9 _marker: std::marker::PhantomData<fn() -> T>,
10}
11
12impl<T> Handle<T> {
13 pub fn new(id: RawAssetHandle) -> Self {
14 Self {
15 id,
16 _marker: std::marker::PhantomData,
17 }
18 }
19}
20
21impl<T> Clone for Handle<T> {
22 fn clone(&self) -> Self {
23 *self
24 }
25}
26impl<T> Copy for Handle<T> {}
27
28impl<T> Default for Handle<T> {
29 fn default() -> Self {
30 Self::new(RawAssetHandle::default())
31 }
32}
33
34impl<T> PartialEq for Handle<T> {
35 fn eq(&self, other: &Self) -> bool {
36 self.id == other.id
37 }
38}
39impl<T> Eq for Handle<T> {}
40
41impl<T> std::hash::Hash for Handle<T> {
42 fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
43 self.id.hash(state);
44 }
45}
46
47impl<T> std::fmt::Debug for Handle<T> {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 f.debug_tuple("Handle").field(&self.id).finish()
50 }
51}