kimchi_stubs/arkworks/
group_projective.rs1use core::ops::{Add, Deref, Neg, Sub};
2use mina_curves::pasta::curves::{pallas::ProjectivePallas, vesta::ProjectiveVesta};
3
4#[derive(Clone, Copy, ocaml_gen::CustomType)]
7pub struct CamlGroupProjectivePallas(pub ProjectivePallas);
8
9unsafe impl<'a> ocaml::FromValue<'a> for CamlGroupProjectivePallas {
10 fn from_value(value: ocaml::Value) -> Self {
11 let x: ocaml::Pointer<Self> = ocaml::FromValue::from_value(value);
12 *x.as_ref()
13 }
14}
15
16impl CamlGroupProjectivePallas {
17 unsafe extern "C" fn caml_pointer_finalize(v: ocaml::Raw) {
18 let ptr = v.as_pointer::<Self>();
19 ptr.drop_in_place()
20 }
21}
22
23ocaml::custom!(CamlGroupProjectivePallas {
24 finalize: CamlGroupProjectivePallas::caml_pointer_finalize,
25});
26
27impl Deref for CamlGroupProjectivePallas {
28 type Target = ProjectivePallas;
29
30 fn deref(&self) -> &Self::Target {
31 &self.0
32 }
33}
34
35impl From<ProjectivePallas> for CamlGroupProjectivePallas {
38 fn from(x: ProjectivePallas) -> Self {
39 CamlGroupProjectivePallas(x)
40 }
41}
42
43impl From<&ProjectivePallas> for CamlGroupProjectivePallas {
44 fn from(x: &ProjectivePallas) -> Self {
45 CamlGroupProjectivePallas(*x)
46 }
47}
48
49impl From<CamlGroupProjectivePallas> for ProjectivePallas {
50 fn from(x: CamlGroupProjectivePallas) -> Self {
51 x.0
52 }
53}
54
55impl From<&CamlGroupProjectivePallas> for ProjectivePallas {
56 fn from(x: &CamlGroupProjectivePallas) -> Self {
57 x.0
58 }
59}
60
61impl Add for CamlGroupProjectivePallas {
62 type Output = Self;
63
64 fn add(self, other: Self) -> Self {
65 Self(self.0 + other.0)
66 }
67}
68
69impl Add for &CamlGroupProjectivePallas {
70 type Output = CamlGroupProjectivePallas;
71
72 fn add(self, other: Self) -> Self::Output {
73 CamlGroupProjectivePallas(self.0 + other.0)
74 }
75}
76
77impl Sub for CamlGroupProjectivePallas {
78 type Output = CamlGroupProjectivePallas;
79
80 fn sub(self, other: Self) -> Self::Output {
81 CamlGroupProjectivePallas(self.0 - other.0)
82 }
83}
84
85impl Sub for &CamlGroupProjectivePallas {
86 type Output = CamlGroupProjectivePallas;
87
88 fn sub(self, other: Self) -> Self::Output {
89 CamlGroupProjectivePallas(self.0 - other.0)
90 }
91}
92
93impl Neg for CamlGroupProjectivePallas {
94 type Output = CamlGroupProjectivePallas;
95
96 fn neg(self) -> Self::Output {
97 CamlGroupProjectivePallas(-self.0)
98 }
99}
100
101impl Neg for &CamlGroupProjectivePallas {
102 type Output = CamlGroupProjectivePallas;
103
104 fn neg(self) -> Self::Output {
105 CamlGroupProjectivePallas(-self.0)
106 }
107}
108
109#[derive(Clone, Copy, ocaml_gen::CustomType)]
112pub struct CamlGroupProjectiveVesta(pub ProjectiveVesta);
113
114unsafe impl<'a> ocaml::FromValue<'a> for CamlGroupProjectiveVesta {
115 fn from_value(value: ocaml::Value) -> Self {
116 let x: ocaml::Pointer<Self> = ocaml::FromValue::from_value(value);
117 *x.as_ref()
118 }
119}
120
121impl CamlGroupProjectiveVesta {
122 unsafe extern "C" fn caml_pointer_finalize(v: ocaml::Raw) {
123 let ptr = v.as_pointer::<Self>();
124 ptr.drop_in_place()
125 }
126}
127
128ocaml::custom!(CamlGroupProjectiveVesta {
129 finalize: CamlGroupProjectiveVesta::caml_pointer_finalize,
130});
131
132impl Deref for CamlGroupProjectiveVesta {
133 type Target = ProjectiveVesta;
134
135 fn deref(&self) -> &Self::Target {
136 &self.0
137 }
138}
139
140impl From<ProjectiveVesta> for CamlGroupProjectiveVesta {
145 fn from(x: ProjectiveVesta) -> Self {
146 CamlGroupProjectiveVesta(x)
147 }
148}
149
150impl From<&ProjectiveVesta> for CamlGroupProjectiveVesta {
151 fn from(x: &ProjectiveVesta) -> Self {
152 CamlGroupProjectiveVesta(*x)
153 }
154}
155
156impl From<CamlGroupProjectiveVesta> for ProjectiveVesta {
157 fn from(x: CamlGroupProjectiveVesta) -> Self {
158 x.0
159 }
160}
161
162impl From<&CamlGroupProjectiveVesta> for ProjectiveVesta {
163 fn from(x: &CamlGroupProjectiveVesta) -> Self {
164 x.0
165 }
166}
167
168impl Add for CamlGroupProjectiveVesta {
169 type Output = Self;
170
171 fn add(self, other: Self) -> Self {
172 Self(self.0 + other.0)
173 }
174}
175impl Add for &CamlGroupProjectiveVesta {
176 type Output = CamlGroupProjectiveVesta;
177
178 fn add(self, other: Self) -> Self::Output {
179 CamlGroupProjectiveVesta(self.0 + other.0)
180 }
181}
182
183impl Sub for CamlGroupProjectiveVesta {
184 type Output = CamlGroupProjectiveVesta;
185
186 fn sub(self, other: Self) -> Self::Output {
187 CamlGroupProjectiveVesta(self.0 - other.0)
188 }
189}
190
191impl Sub for &CamlGroupProjectiveVesta {
192 type Output = CamlGroupProjectiveVesta;
193
194 fn sub(self, other: Self) -> Self::Output {
195 CamlGroupProjectiveVesta(self.0 - other.0)
196 }
197}
198
199impl Neg for CamlGroupProjectiveVesta {
200 type Output = CamlGroupProjectiveVesta;
201
202 fn neg(self) -> Self::Output {
203 CamlGroupProjectiveVesta(-self.0)
204 }
205}
206
207impl Neg for &CamlGroupProjectiveVesta {
208 type Output = CamlGroupProjectiveVesta;
209
210 fn neg(self) -> Self::Output {
211 CamlGroupProjectiveVesta(-self.0)
212 }
213}