1use crate::{AsnType, Tag};
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
5pub struct Explicit<T, V> {
6 _tag: core::marker::PhantomData<T>,
7 pub value: V,
9}
10
11#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
13pub struct Implicit<T, V> {
14 _tag: core::marker::PhantomData<T>,
15 pub value: V,
17}
18
19macro_rules! tag_kind {
20 ($($name:ident),+) => {
21 $(
22
23 impl<T, V> $name<T, V>{
24 pub fn new(value: V) -> Self {
26 Self {
27 value,
28 _tag: core::marker::PhantomData,
29 }
30 }
31 }
32
33 impl<T, V> From<V> for $name<T, V> {
34 fn from(value: V) -> Self {
35 Self::new(value)
36 }
37 }
38
39 impl<T, V> core::ops::Deref for $name<T, V> {
40 type Target = V;
41
42 fn deref(&self) -> &Self::Target {
43 &self.value
44 }
45 }
46
47 impl<T, V> core::ops::DerefMut for $name<T, V> {
48 fn deref_mut(&mut self) -> &mut Self::Target {
49 &mut self.value
50 }
51 }
52 )+
53 }
54}
55
56tag_kind!(Implicit, Explicit);
57
58impl<T: AsnType, V> AsnType for Implicit<T, V> {
59 const TAG: Tag = T::TAG;
60}
61
62impl<T: AsnType, V> AsnType for Explicit<T, V> {
63 const TAG: Tag = T::TAG;
64}