miden_base_sys/bindings/
types.rs1use miden_stdlib_sys::{Felt, Word};
2
3#[allow(unused)]
4#[derive(Copy, Clone, Debug, PartialEq, Eq)]
5pub struct AccountId {
6 pub prefix: Felt,
7 pub suffix: Felt,
8}
9
10impl AccountId {
11 pub fn from(prefix: Felt, suffix: Felt) -> Self {
13 Self { prefix, suffix }
14 }
15}
16
17#[derive(Copy, Clone, Debug, PartialEq, Eq)]
18#[repr(transparent)]
19pub struct Asset {
20 pub inner: Word,
21}
22
23impl Asset {
24 pub fn new(word: impl Into<Word>) -> Self {
25 Asset { inner: word.into() }
26 }
27
28 pub fn as_word(&self) -> &Word {
29 &self.inner
30 }
31
32 #[inline]
33 pub(crate) fn reverse(&self) -> Self {
34 Self {
35 inner: self.inner.reverse(),
36 }
37 }
38}
39
40impl From<Word> for Asset {
41 fn from(value: Word) -> Self {
42 Self::new(value)
43 }
44}
45
46impl From<[Felt; 4]> for Asset {
47 fn from(value: [Felt; 4]) -> Self {
48 Asset::new(Word::from(value))
49 }
50}
51
52impl From<Asset> for Word {
53 fn from(val: Asset) -> Self {
54 val.inner
55 }
56}
57
58impl AsRef<Word> for Asset {
59 fn as_ref(&self) -> &Word {
60 &self.inner
61 }
62}
63
64#[derive(Clone, Debug, PartialEq, Eq)]
65#[repr(transparent)]
66pub struct Recipient {
67 pub inner: Word,
68}
69
70impl From<[Felt; 4]> for Recipient {
71 fn from(value: [Felt; 4]) -> Self {
72 Recipient {
73 inner: Word::from(value),
74 }
75 }
76}
77
78impl From<Word> for Recipient {
79 fn from(value: Word) -> Self {
80 Recipient { inner: value }
81 }
82}
83
84#[derive(Clone, Copy, Debug, PartialEq, Eq)]
85#[repr(transparent)]
86pub struct Tag {
87 pub inner: Felt,
88}
89
90impl From<Felt> for Tag {
91 fn from(value: Felt) -> Self {
92 Tag { inner: value }
93 }
94}
95
96#[derive(Clone, Copy, Debug, PartialEq, Eq)]
97#[repr(transparent)]
98pub struct NoteIdx {
99 pub inner: Felt,
100}
101
102#[derive(Clone, Copy, Debug, PartialEq, Eq)]
103#[repr(transparent)]
104pub struct NoteType {
105 pub inner: Felt,
106}
107
108impl From<Felt> for NoteType {
109 fn from(value: Felt) -> Self {
110 NoteType { inner: value }
111 }
112}
113
114#[derive(Clone, Debug, PartialEq, Eq)]
115#[repr(transparent)]
116pub struct StorageCommitmentRoot(Word);
117
118impl StorageCommitmentRoot {
119 #[inline]
120 pub(crate) fn reverse(&self) -> StorageCommitmentRoot {
121 Self(self.0.reverse())
122 }
123}