snarkvm_console_network_environment/traits/
arithmetic.rs1use anyhow::Result;
17
18pub trait AddChecked<Rhs: ?Sized = Self> {
20 type Output;
21
22 fn add_checked(&self, rhs: &Rhs) -> Self::Output;
23}
24
25pub trait AddSaturating<Rhs: ?Sized = Self> {
27 type Output;
28
29 fn add_saturating(&self, rhs: &Rhs) -> Self::Output;
30}
31
32pub trait AddWrapped<Rhs: ?Sized = Self> {
34 type Output;
35
36 fn add_wrapped(&self, rhs: &Rhs) -> Self::Output;
37}
38
39pub trait DivUnchecked<Rhs: ?Sized = Self> {
41 type Output;
42
43 fn div_unchecked(&self, rhs: &Rhs) -> Self::Output;
44}
45
46pub trait DivChecked<Rhs: ?Sized = Self> {
48 type Output;
49
50 fn div_checked(&self, rhs: &Rhs) -> Self::Output;
51}
52
53pub trait DivSaturating<Rhs: ?Sized = Self> {
55 type Output;
56
57 fn div_saturating(&self, rhs: &Rhs) -> Self::Output;
58}
59
60pub trait DivWrapped<Rhs: ?Sized = Self> {
62 type Output;
63
64 fn div_wrapped(&self, rhs: &Rhs) -> Self::Output;
65}
66
67pub trait Modulo<Rhs: ?Sized = Self> {
69 type Output;
70
71 fn modulo(&self, rhs: &Rhs) -> Self::Output;
72}
73
74pub trait MulChecked<Rhs: ?Sized = Self> {
76 type Output;
77
78 fn mul_checked(&self, rhs: &Rhs) -> Self::Output;
79}
80
81pub trait MulSaturating<Rhs: ?Sized = Self> {
83 type Output;
84
85 fn mul_saturating(&self, rhs: &Rhs) -> Self::Output;
86}
87
88pub trait MulWrapped<Rhs: ?Sized = Self> {
90 type Output;
91
92 fn mul_wrapped(&self, rhs: &Rhs) -> Self::Output;
93}
94
95pub trait PowChecked<Rhs: ?Sized = Self> {
97 type Output;
98
99 fn pow_checked(&self, rhs: &Rhs) -> Self::Output;
100}
101
102pub trait PowWrapped<Rhs: ?Sized = Self> {
104 type Output;
105
106 fn pow_wrapped(&self, rhs: &Rhs) -> Self::Output;
107}
108
109pub trait RemChecked<Rhs: ?Sized = Self> {
111 type Output;
112
113 fn rem_checked(&self, rhs: &Rhs) -> Self::Output;
114}
115
116pub trait RemSaturating<Rhs: ?Sized = Self> {
118 type Output;
119
120 fn rem_saturating(&self, rhs: &Rhs) -> Self::Output;
121}
122
123pub trait RemWrapped<Rhs: ?Sized = Self> {
125 type Output;
126
127 fn rem_wrapped(&self, rhs: &Rhs) -> Self::Output;
128}
129
130pub trait ShlChecked<Rhs: ?Sized = Self> {
133 type Output;
134
135 fn shl_checked(&self, rhs: &Rhs) -> Self::Output;
136}
137
138pub trait ShlWrapped<Rhs: ?Sized = Self> {
140 type Output;
141
142 fn shl_wrapped(&self, rhs: &Rhs) -> Self::Output;
143}
144
145pub trait ShrChecked<Rhs: ?Sized = Self> {
148 type Output;
149
150 fn shr_checked(&self, rhs: &Rhs) -> Self::Output;
151}
152
153pub trait ShrWrapped<Rhs: ?Sized = Self> {
155 type Output;
156
157 fn shr_wrapped(&self, rhs: &Rhs) -> Self::Output;
158}
159
160pub trait SubChecked<Rhs: ?Sized = Self> {
162 type Output;
163
164 fn sub_checked(&self, rhs: &Rhs) -> Self::Output;
165}
166
167pub trait SubSaturating<Rhs: ?Sized = Self> {
169 type Output;
170
171 fn sub_saturating(&self, rhs: &Rhs) -> Self::Output;
172}
173
174pub trait SubWrapped<Rhs: ?Sized = Self> {
176 type Output;
177
178 fn sub_wrapped(&self, rhs: &Rhs) -> Self::Output;
179}
180
181pub trait AbsChecked {
183 type Output;
184
185 fn abs_checked(self) -> Self::Output;
186}
187
188pub trait AbsSaturating {
190 type Output;
191
192 fn abs_saturating(self) -> Self::Output;
193}
194
195pub trait AbsWrapped {
197 type Output;
198
199 fn abs_wrapped(self) -> Self::Output;
200}
201
202pub trait Double {
204 type Output;
205
206 fn double(&self) -> Self::Output;
207}
208
209pub trait Inverse {
211 type Output;
212
213 fn inverse(&self) -> Result<Self::Output>;
214}
215
216pub trait Square {
218 type Output;
219
220 fn square(&self) -> Self::Output;
221}
222
223pub trait SquareRoot {
225 type Output;
226
227 fn square_root(&self) -> Result<Self::Output>;
228}