1use crate::types::{Class, Tag};
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
5pub struct Identifier {
6 pub tag: Tag,
8 pub(crate) is_constructed: bool,
10}
11
12impl Identifier {
13 #[must_use]
15 pub fn new(class: Class, is_constructed: bool, tag: u32) -> Self {
16 Self {
17 tag: Tag::new(class, tag),
18 is_constructed,
19 }
20 }
21
22 #[must_use]
24 pub fn from_tag(tag: Tag, is_constructed: bool) -> Self {
25 Self {
26 tag,
27 is_constructed,
28 }
29 }
30
31 #[must_use]
33 pub fn tag(self, tag: u32) -> Self {
34 Self {
35 tag: self.tag.set_value(tag),
36 is_constructed: self.is_constructed,
37 }
38 }
39
40 #[must_use]
43 pub fn is_constructed(&self) -> bool {
44 self.is_constructed
45 }
46
47 #[must_use]
50 pub fn is_primitive(&self) -> bool {
51 !self.is_constructed()
52 }
53}
54
55impl core::ops::Deref for Identifier {
56 type Target = Tag;
57
58 fn deref(&self) -> &Self::Target {
59 &self.tag
60 }
61}