rspack_core/dependency/
dependency_id.rs1use rspack_cacheable::cacheable;
2use rspack_tasks::fetch_new_dependency_id;
3use serde::Serialize;
4
5#[cacheable(hashable)]
6#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, Ord, PartialOrd, Serialize)]
7pub struct DependencyId(u32);
8
9impl DependencyId {
10 pub fn new() -> Self {
11 let id = fetch_new_dependency_id();
12 Self(id)
13 }
14
15 pub fn as_u32(&self) -> u32 {
16 self.0
17 }
18}
19
20impl Default for DependencyId {
21 fn default() -> Self {
22 Self::new()
23 }
24}
25
26impl std::ops::Deref for DependencyId {
27 type Target = u32;
28
29 fn deref(&self) -> &Self::Target {
30 &self.0
31 }
32}
33
34impl From<u32> for DependencyId {
35 fn from(id: u32) -> Self {
36 Self(id)
37 }
38}