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