miden_project/dependencies/resolver/
package_id.rs1use alloc::{string::ToString, sync::Arc};
2use core::{borrow::Borrow, fmt, ops::Deref};
3
4#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[repr(transparent)]
11pub struct PackageId(Arc<str>);
12
13impl Borrow<str> for PackageId {
14 fn borrow(&self) -> &str {
15 &self.0
16 }
17}
18
19impl Borrow<Arc<str>> for PackageId {
20 fn borrow(&self) -> &Arc<str> {
21 &self.0
22 }
23}
24
25impl fmt::Display for PackageId {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 fmt::Display::fmt(&self.0, f)
28 }
29}
30
31impl AsRef<str> for PackageId {
32 #[inline(always)]
33 fn as_ref(&self) -> &str {
34 self.0.as_ref()
35 }
36}
37
38impl AsRef<Arc<str>> for PackageId {
39 #[inline(always)]
40 fn as_ref(&self) -> &Arc<str> {
41 &self.0
42 }
43}
44
45impl Deref for PackageId {
46 type Target = str;
47
48 #[inline(always)]
49 fn deref(&self) -> &Self::Target {
50 self.0.as_ref()
51 }
52}
53
54impl From<Arc<str>> for PackageId {
55 fn from(value: Arc<str>) -> Self {
56 Self(value)
57 }
58}
59
60impl From<&str> for PackageId {
61 fn from(value: &str) -> Self {
62 Self(value.to_string().into_boxed_str().into())
63 }
64}