miden_base_sys/bindings/
types.rs

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