1pub mod rust;
2
3pub mod casper {
4 include!(concat!(env!("OUT_DIR"), "/casper.rs"));
5 pub mod v1 {
6 tonic::include_proto!("casper.v1");
7 }
8}
9
10pub mod rhoapi {
11 include!(concat!(env!("OUT_DIR"), "/rhoapi.rs"));
12}
13
14pub mod rholang_scala_rust_types {
15 include!(concat!(env!("OUT_DIR"), "/rholang_scala_rust_types.rs"));
16}
17
18pub mod rspace_plus_plus_types {
19 include!(concat!(env!("OUT_DIR"), "/rspace_plus_plus_types.rs"));
20}
21
22pub mod servicemodelapi {
23 include!(concat!(env!("OUT_DIR"), "/servicemodelapi.rs"));
24}
25
26pub type ByteVector = Vec<u8>;
27pub type ByteBuffer = Vec<u8>;
28pub type Byte = u8;
29pub type ByteString = Vec<u8>;
30pub type BitSet = Vec<u8>;
31
32pub fn create_bit_vector(indices: &[usize]) -> BitSet {
33 let max_index = *indices.iter().max().unwrap_or(&0);
34 let mut bit_vector = vec![0; max_index + 1];
35 for &index in indices {
36 bit_vector[index] = 1;
37 }
38 bit_vector
40}
41
42use crate::connective::ConnectiveInstance;
43use crate::expr::ExprInstance;
44use crate::rhoapi::*;
45use crate::servicemodelapi::ServiceError;
46use crate::var::VarInstance;
47use g_unforgeable::UnfInstance;
48use tagged_continuation::TaggedCont;
49use var::WildcardMsg;
50
51use std::error::Error;
52use std::fmt;
53use std::hash::{Hash, Hasher};
54
55impl PartialEq for Par {
58 fn eq(&self, other: &Self) -> bool {
59 self.sends == other.sends
60 && self.receives == other.receives
61 && self.news == other.news
62 && self.exprs == other.exprs
63 && self.matches == other.matches
64 && self.unforgeables == other.unforgeables
65 && self.bundles == other.bundles
66 && self.connectives == other.connectives
67 && self.connective_used == other.connective_used
68 }
69}
70
71impl Hash for Par {
72 fn hash<H: Hasher>(&self, state: &mut H) {
73 self.sends.hash(state);
74 self.receives.hash(state);
75 self.news.hash(state);
76 self.exprs.hash(state);
77 self.matches.hash(state);
78 self.unforgeables.hash(state);
79 self.bundles.hash(state);
80 self.connectives.hash(state);
81 self.connective_used.hash(state);
82 }
83}
84
85impl PartialEq for TaggedContinuation {
86 fn eq(&self, other: &Self) -> bool {
87 self.tagged_cont == other.tagged_cont
88 }
89}
90
91impl Hash for TaggedContinuation {
92 fn hash<H: Hasher>(&self, state: &mut H) {
93 self.tagged_cont.hash(state);
94 }
95}
96
97impl PartialEq for TaggedCont {
98 fn eq(&self, other: &Self) -> bool {
99 match (self, other) {
100 (TaggedCont::ParBody(par_body), TaggedCont::ParBody(other_par_body)) => {
101 par_body == other_par_body
102 }
103
104 (
105 TaggedCont::ScalaBodyRef(scala_body_ref),
106 TaggedCont::ScalaBodyRef(other_scala_body_ref),
107 ) => scala_body_ref == other_scala_body_ref,
108
109 _ => false,
110 }
111 }
112}
113
114impl Hash for TaggedCont {
115 fn hash<H: Hasher>(&self, state: &mut H) {
116 match self {
117 TaggedCont::ParBody(par_body) => par_body.hash(state),
118 TaggedCont::ScalaBodyRef(scala_body_ref) => scala_body_ref.hash(state),
119 }
120 }
121}
122
123impl PartialEq for ParWithRandom {
124 fn eq(&self, other: &Self) -> bool {
125 self.body == other.body && self.random_state == other.random_state
126 }
127}
128
129impl Hash for ParWithRandom {
130 fn hash<H: Hasher>(&self, state: &mut H) {
131 self.body.hash(state);
132 self.random_state.hash(state);
133 }
134}
135
136impl PartialEq for PCost {
137 fn eq(&self, other: &Self) -> bool {
138 self.cost == other.cost
139 }
140}
141
142impl Hash for PCost {
143 fn hash<H: Hasher>(&self, state: &mut H) {
144 self.cost.hash(state);
145 }
146}
147
148impl PartialEq for ListParWithRandom {
149 fn eq(&self, other: &Self) -> bool {
150 self.pars == other.pars && self.random_state == other.random_state
151 }
152}
153
154impl Hash for ListParWithRandom {
155 fn hash<H: Hasher>(&self, state: &mut H) {
156 self.pars.hash(state);
157 self.random_state.hash(state);
158 }
159}
160
161impl PartialEq for Var {
162 fn eq(&self, other: &Self) -> bool {
163 self.var_instance == other.var_instance
164 }
165}
166
167impl Hash for Var {
168 fn hash<H: Hasher>(&self, state: &mut H) {
169 self.var_instance.hash(state);
170 }
171}
172
173impl PartialEq for VarInstance {
174 fn eq(&self, other: &Self) -> bool {
175 match (self, other) {
176 (VarInstance::BoundVar(a), VarInstance::BoundVar(b)) => a == b,
177 (VarInstance::FreeVar(a), VarInstance::FreeVar(b)) => a == b,
178 (VarInstance::Wildcard(a), VarInstance::Wildcard(b)) => a == b,
179 _ => false,
180 }
181 }
182}
183
184impl Hash for VarInstance {
185 fn hash<H: Hasher>(&self, state: &mut H) {
186 match self {
187 VarInstance::BoundVar(a) => a.hash(state),
188 VarInstance::FreeVar(a) => a.hash(state),
189 VarInstance::Wildcard(a) => a.hash(state),
190 }
191 }
192}
193
194impl PartialEq for WildcardMsg {
195 fn eq(&self, _other: &Self) -> bool {
196 true
197 }
198}
199
200impl Hash for WildcardMsg {
201 fn hash<H: Hasher>(&self, _state: &mut H) {
202 }
204}
205
206impl PartialEq for Bundle {
207 fn eq(&self, other: &Self) -> bool {
208 self.body == other.body
209 && self.write_flag == other.write_flag
210 && self.read_flag == other.read_flag
211 }
212}
213
214impl Hash for Bundle {
215 fn hash<H: Hasher>(&self, state: &mut H) {
216 self.body.hash(state);
217 self.write_flag.hash(state);
218 self.read_flag.hash(state);
219 }
220}
221
222impl PartialEq for Send {
223 fn eq(&self, other: &Self) -> bool {
224 self.chan == other.chan
225 && self.data == other.data
226 && self.persistent == other.persistent
227 && self.connective_used == other.connective_used
228 }
229}
230
231impl Hash for Send {
232 fn hash<H: Hasher>(&self, state: &mut H) {
233 self.chan.hash(state);
234 self.data.hash(state);
235 self.persistent.hash(state);
236 self.connective_used.hash(state);
237 }
238}
239
240impl PartialEq for ReceiveBind {
241 fn eq(&self, other: &Self) -> bool {
242 self.patterns == other.patterns
243 && self.source == other.source
244 && self.remainder == other.remainder
245 && self.free_count == other.free_count
246 }
247}
248
249impl Hash for ReceiveBind {
250 fn hash<H: Hasher>(&self, state: &mut H) {
251 self.patterns.hash(state);
252 self.source.hash(state);
253 self.remainder.hash(state);
254 self.free_count.hash(state);
255 }
256}
257
258impl PartialEq for BindPattern {
259 fn eq(&self, other: &Self) -> bool {
260 self.patterns == other.patterns
261 && self.remainder == other.remainder
262 && self.free_count == other.free_count
263 }
264}
265
266impl Hash for BindPattern {
267 fn hash<H: Hasher>(&self, state: &mut H) {
268 self.patterns.hash(state);
269 self.remainder.hash(state);
270 self.free_count.hash(state);
271 }
272}
273
274impl PartialEq for ListBindPatterns {
275 fn eq(&self, other: &Self) -> bool {
276 self.patterns == other.patterns
277 }
278}
279
280impl Hash for ListBindPatterns {
281 fn hash<H: Hasher>(&self, state: &mut H) {
282 self.patterns.hash(state);
283 }
284}
285
286impl PartialEq for Receive {
287 fn eq(&self, other: &Self) -> bool {
288 self.binds == other.binds
289 && self.body == other.body
290 && self.persistent == other.persistent
291 && self.peek == other.peek
292 && self.bind_count == other.bind_count
293 && self.connective_used == other.connective_used
294 }
295}
296
297impl Hash for Receive {
298 fn hash<H: Hasher>(&self, state: &mut H) {
299 self.binds.hash(state);
300 self.body.hash(state);
301 self.persistent.hash(state);
302 self.peek.hash(state);
303 self.bind_count.hash(state);
304 self.connective_used.hash(state);
305 }
306}
307
308impl PartialEq for New {
309 fn eq(&self, other: &Self) -> bool {
310 self.bind_count == other.bind_count
311 && self.p == other.p
312 && self.uri == other.uri
313 && self.injections == other.injections
314 }
315}
316
317impl Hash for New {
318 fn hash<H: Hasher>(&self, state: &mut H) {
319 self.bind_count.hash(state);
320 self.p.hash(state);
321 self.uri.hash(state);
322 self.injections.hash(state);
323 }
324}
325
326impl PartialEq for MatchCase {
327 fn eq(&self, other: &Self) -> bool {
328 self.pattern == other.pattern
329 && self.source == other.source
330 && self.free_count == other.free_count
331 }
332}
333
334impl Hash for MatchCase {
335 fn hash<H: Hasher>(&self, state: &mut H) {
336 self.pattern.hash(state);
337 self.source.hash(state);
338 self.free_count.hash(state);
339 }
340}
341
342impl PartialEq for Match {
343 fn eq(&self, other: &Self) -> bool {
344 self.target == other.target
345 && self.cases == other.cases
346 && self.connective_used == other.connective_used
347 }
348}
349
350impl Hash for Match {
351 fn hash<H: Hasher>(&self, state: &mut H) {
352 self.target.hash(state);
353 self.cases.hash(state);
354 self.connective_used.hash(state);
355 }
356}
357
358impl PartialEq for Expr {
359 fn eq(&self, other: &Self) -> bool {
360 self.expr_instance == other.expr_instance
361 }
362}
363
364impl Hash for Expr {
365 fn hash<H: Hasher>(&self, state: &mut H) {
366 self.expr_instance.hash(state);
367 }
368}
369
370impl PartialEq for expr::ExprInstance {
371 fn eq(&self, other: &Self) -> bool {
372 match (self, other) {
373 (ExprInstance::GBool(a), ExprInstance::GBool(b)) => a == b,
374 (ExprInstance::GInt(a), ExprInstance::GInt(b)) => a == b,
375 (ExprInstance::GString(a), ExprInstance::GString(b)) => a == b,
376 (ExprInstance::GUri(a), ExprInstance::GUri(b)) => a == b,
377 (ExprInstance::GByteArray(a), ExprInstance::GByteArray(b)) => a == b,
378 (ExprInstance::ENotBody(a), ExprInstance::ENotBody(b)) => a == b,
379 (ExprInstance::ENegBody(a), ExprInstance::ENegBody(b)) => a == b,
380 (ExprInstance::EMultBody(a), ExprInstance::EMultBody(b)) => a == b,
381 (ExprInstance::EDivBody(a), ExprInstance::EDivBody(b)) => a == b,
382 (ExprInstance::EPlusBody(a), ExprInstance::EPlusBody(b)) => a == b,
383 (ExprInstance::EMinusBody(a), ExprInstance::EMinusBody(b)) => a == b,
384 (ExprInstance::ELtBody(a), ExprInstance::ELtBody(b)) => a == b,
385 (ExprInstance::ELteBody(a), ExprInstance::ELteBody(b)) => a == b,
386 (ExprInstance::EGtBody(a), ExprInstance::EGtBody(b)) => a == b,
387 (ExprInstance::EGteBody(a), ExprInstance::EGteBody(b)) => a == b,
388 (ExprInstance::EEqBody(a), ExprInstance::EEqBody(b)) => a == b,
389 (ExprInstance::ENeqBody(a), ExprInstance::ENeqBody(b)) => a == b,
390 (ExprInstance::EAndBody(a), ExprInstance::EAndBody(b)) => a == b,
391 (ExprInstance::EOrBody(a), ExprInstance::EOrBody(b)) => a == b,
392 (ExprInstance::EVarBody(a), ExprInstance::EVarBody(b)) => a == b,
393 (ExprInstance::EListBody(a), ExprInstance::EListBody(b)) => a == b,
394 (ExprInstance::ETupleBody(a), ExprInstance::ETupleBody(b)) => a == b,
395 (ExprInstance::ESetBody(a), ExprInstance::ESetBody(b)) => a == b,
396 (ExprInstance::EMapBody(a), ExprInstance::EMapBody(b)) => a == b,
397 (ExprInstance::EMethodBody(a), ExprInstance::EMethodBody(b)) => a == b,
398 (ExprInstance::EMatchesBody(a), ExprInstance::EMatchesBody(b)) => a == b,
399 (ExprInstance::EPercentPercentBody(a), ExprInstance::EPercentPercentBody(b)) => a == b,
400 (ExprInstance::EPlusPlusBody(a), ExprInstance::EPlusPlusBody(b)) => a == b,
401 (ExprInstance::EMinusMinusBody(a), ExprInstance::EMinusMinusBody(b)) => a == b,
402 (ExprInstance::EModBody(a), ExprInstance::EModBody(b)) => a == b,
403 _ => false,
404 }
405 }
406}
407
408impl Hash for expr::ExprInstance {
409 fn hash<H: Hasher>(&self, state: &mut H) {
410 match self {
411 ExprInstance::GBool(a) => a.hash(state),
412 ExprInstance::GInt(a) => a.hash(state),
413 ExprInstance::GString(a) => a.hash(state),
414 ExprInstance::GUri(a) => a.hash(state),
415 ExprInstance::GByteArray(a) => a.hash(state),
416 ExprInstance::ENotBody(a) => a.hash(state),
417 ExprInstance::ENegBody(a) => a.hash(state),
418 ExprInstance::EMultBody(a) => a.hash(state),
419 ExprInstance::EDivBody(a) => a.hash(state),
420 ExprInstance::EPlusBody(a) => a.hash(state),
421 ExprInstance::EMinusBody(a) => a.hash(state),
422 ExprInstance::ELtBody(a) => a.hash(state),
423 ExprInstance::ELteBody(a) => a.hash(state),
424 ExprInstance::EGtBody(a) => a.hash(state),
425 ExprInstance::EGteBody(a) => a.hash(state),
426 ExprInstance::EEqBody(a) => a.hash(state),
427 ExprInstance::ENeqBody(a) => a.hash(state),
428 ExprInstance::EAndBody(a) => a.hash(state),
429 ExprInstance::EOrBody(a) => a.hash(state),
430 ExprInstance::EVarBody(a) => a.hash(state),
431 ExprInstance::EListBody(a) => a.hash(state),
432 ExprInstance::ETupleBody(a) => a.hash(state),
433 ExprInstance::ESetBody(a) => a.hash(state),
434 ExprInstance::EMapBody(a) => a.hash(state),
435 ExprInstance::EMethodBody(a) => a.hash(state),
436 ExprInstance::EMatchesBody(a) => a.hash(state),
437 ExprInstance::EPercentPercentBody(a) => a.hash(state),
438 ExprInstance::EPlusPlusBody(a) => a.hash(state),
439 ExprInstance::EMinusMinusBody(a) => a.hash(state),
440 ExprInstance::EModBody(a) => a.hash(state),
441 }
442 }
443}
444
445impl PartialEq for EList {
446 fn eq(&self, other: &Self) -> bool {
447 self.ps == other.ps
448 && self.connective_used == other.connective_used
449 && self.remainder == other.remainder
450 }
451}
452
453impl Hash for EList {
454 fn hash<H: Hasher>(&self, state: &mut H) {
455 self.ps.hash(state);
456 self.connective_used.hash(state);
457 self.remainder.hash(state);
458 }
459}
460
461impl PartialEq for ETuple {
462 fn eq(&self, other: &Self) -> bool {
463 self.ps == other.ps && self.connective_used == other.connective_used
464 }
465}
466
467impl Hash for ETuple {
468 fn hash<H: Hasher>(&self, state: &mut H) {
469 self.ps.hash(state);
470 self.connective_used.hash(state);
471 }
472}
473
474impl PartialEq for ESet {
475 fn eq(&self, other: &Self) -> bool {
476 self.ps == other.ps
477 && self.connective_used == other.connective_used
478 && self.remainder == other.remainder
479 }
480}
481
482impl Hash for ESet {
483 fn hash<H: Hasher>(&self, state: &mut H) {
484 self.ps.hash(state);
485 self.connective_used.hash(state);
486 self.remainder.hash(state);
487 }
488}
489
490impl PartialEq for EMap {
491 fn eq(&self, other: &Self) -> bool {
492 self.kvs == other.kvs
493 && self.connective_used == other.connective_used
494 && self.remainder == other.remainder
495 }
496}
497
498impl Hash for EMap {
499 fn hash<H: Hasher>(&self, state: &mut H) {
500 self.kvs.hash(state);
501 self.connective_used.hash(state);
502 self.remainder.hash(state);
503 }
504}
505
506impl PartialEq for EMethod {
507 fn eq(&self, other: &Self) -> bool {
508 self.method_name == other.method_name
509 && self.target == other.target
510 && self.arguments == other.arguments
511 && self.connective_used == other.connective_used
512 }
513}
514
515impl Hash for EMethod {
516 fn hash<H: Hasher>(&self, state: &mut H) {
517 self.method_name.hash(state);
518 self.target.hash(state);
519 self.arguments.hash(state);
520 self.connective_used.hash(state);
521 }
522}
523
524impl PartialEq for KeyValuePair {
525 fn eq(&self, other: &Self) -> bool {
526 self.key == other.key && self.value == other.value
527 }
528}
529
530impl Hash for KeyValuePair {
531 fn hash<H: Hasher>(&self, state: &mut H) {
532 self.key.hash(state);
533 self.value.hash(state);
534 }
535}
536
537impl PartialEq for EVar {
538 fn eq(&self, other: &Self) -> bool {
539 self.v == other.v
540 }
541}
542
543impl Hash for EVar {
544 fn hash<H: Hasher>(&self, state: &mut H) {
545 self.v.hash(state);
546 }
547}
548
549impl PartialEq for ENot {
550 fn eq(&self, other: &Self) -> bool {
551 self.p == other.p
552 }
553}
554
555impl Hash for ENot {
556 fn hash<H: Hasher>(&self, state: &mut H) {
557 self.p.hash(state);
558 }
559}
560
561impl PartialEq for ENeg {
562 fn eq(&self, other: &Self) -> bool {
563 self.p == other.p
564 }
565}
566
567impl Hash for ENeg {
568 fn hash<H: Hasher>(&self, state: &mut H) {
569 self.p.hash(state);
570 }
571}
572
573impl PartialEq for EMult {
574 fn eq(&self, other: &Self) -> bool {
575 self.p1 == other.p1 && self.p2 == other.p2
576 }
577}
578
579impl Hash for EMult {
580 fn hash<H: Hasher>(&self, state: &mut H) {
581 self.p1.hash(state);
582 self.p2.hash(state);
583 }
584}
585
586impl PartialEq for EDiv {
587 fn eq(&self, other: &Self) -> bool {
588 self.p1 == other.p1 && self.p2 == other.p2
589 }
590}
591
592impl Hash for EDiv {
593 fn hash<H: Hasher>(&self, state: &mut H) {
594 self.p1.hash(state);
595 self.p2.hash(state);
596 }
597}
598
599impl PartialEq for EMod {
600 fn eq(&self, other: &Self) -> bool {
601 self.p1 == other.p1 && self.p2 == other.p2
602 }
603}
604
605impl Hash for EMod {
606 fn hash<H: Hasher>(&self, state: &mut H) {
607 self.p1.hash(state);
608 self.p2.hash(state);
609 }
610}
611
612impl PartialEq for EPlus {
613 fn eq(&self, other: &Self) -> bool {
614 self.p1 == other.p1 && self.p2 == other.p2
615 }
616}
617
618impl Hash for EPlus {
619 fn hash<H: Hasher>(&self, state: &mut H) {
620 self.p1.hash(state);
621 self.p2.hash(state);
622 }
623}
624
625impl PartialEq for EMinus {
626 fn eq(&self, other: &Self) -> bool {
627 self.p1 == other.p1 && self.p2 == other.p2
628 }
629}
630
631impl Hash for EMinus {
632 fn hash<H: Hasher>(&self, state: &mut H) {
633 self.p1.hash(state);
634 self.p2.hash(state);
635 }
636}
637
638impl PartialEq for ELt {
639 fn eq(&self, other: &Self) -> bool {
640 self.p1 == other.p1 && self.p2 == other.p2
641 }
642}
643
644impl Hash for ELt {
645 fn hash<H: Hasher>(&self, state: &mut H) {
646 self.p1.hash(state);
647 self.p2.hash(state);
648 }
649}
650
651impl PartialEq for ELte {
652 fn eq(&self, other: &Self) -> bool {
653 self.p1 == other.p1 && self.p2 == other.p2
654 }
655}
656
657impl Hash for ELte {
658 fn hash<H: Hasher>(&self, state: &mut H) {
659 self.p1.hash(state);
660 self.p2.hash(state);
661 }
662}
663
664impl PartialEq for EGt {
665 fn eq(&self, other: &Self) -> bool {
666 self.p1 == other.p1 && self.p2 == other.p2
667 }
668}
669
670impl Hash for EGt {
671 fn hash<H: Hasher>(&self, state: &mut H) {
672 self.p1.hash(state);
673 self.p2.hash(state);
674 }
675}
676
677impl PartialEq for EGte {
678 fn eq(&self, other: &Self) -> bool {
679 self.p1 == other.p1 && self.p2 == other.p2
680 }
681}
682
683impl Hash for EGte {
684 fn hash<H: Hasher>(&self, state: &mut H) {
685 self.p1.hash(state);
686 self.p2.hash(state);
687 }
688}
689
690impl PartialEq for EEq {
691 fn eq(&self, other: &Self) -> bool {
692 self.p1 == other.p1 && self.p2 == other.p2
693 }
694}
695
696impl Hash for EEq {
697 fn hash<H: Hasher>(&self, state: &mut H) {
698 self.p1.hash(state);
699 self.p2.hash(state);
700 }
701}
702
703impl PartialEq for ENeq {
704 fn eq(&self, other: &Self) -> bool {
705 self.p1 == other.p1 && self.p2 == other.p2
706 }
707}
708
709impl Hash for ENeq {
710 fn hash<H: Hasher>(&self, state: &mut H) {
711 self.p1.hash(state);
712 self.p2.hash(state);
713 }
714}
715
716impl PartialEq for EAnd {
717 fn eq(&self, other: &Self) -> bool {
718 self.p1 == other.p1 && self.p2 == other.p2
719 }
720}
721
722impl Hash for EAnd {
723 fn hash<H: Hasher>(&self, state: &mut H) {
724 self.p1.hash(state);
725 self.p2.hash(state);
726 }
727}
728
729impl PartialEq for EOr {
730 fn eq(&self, other: &Self) -> bool {
731 self.p1 == other.p1 && self.p2 == other.p2
732 }
733}
734
735impl Hash for EOr {
736 fn hash<H: Hasher>(&self, state: &mut H) {
737 self.p1.hash(state);
738 self.p2.hash(state);
739 }
740}
741
742impl PartialEq for EMatches {
743 fn eq(&self, other: &Self) -> bool {
744 self.target == other.target && self.pattern == other.pattern
745 }
746}
747
748impl Hash for EMatches {
749 fn hash<H: Hasher>(&self, state: &mut H) {
750 self.target.hash(state);
751 self.pattern.hash(state);
752 }
753}
754
755impl PartialEq for EPercentPercent {
756 fn eq(&self, other: &Self) -> bool {
757 self.p1 == other.p1 && self.p2 == other.p2
758 }
759}
760
761impl Hash for EPercentPercent {
762 fn hash<H: Hasher>(&self, state: &mut H) {
763 self.p1.hash(state);
764 self.p2.hash(state);
765 }
766}
767
768impl PartialEq for EPlusPlus {
769 fn eq(&self, other: &Self) -> bool {
770 self.p1 == other.p1 && self.p2 == other.p2
771 }
772}
773
774impl Hash for EPlusPlus {
775 fn hash<H: Hasher>(&self, state: &mut H) {
776 self.p1.hash(state);
777 self.p2.hash(state);
778 }
779}
780
781impl PartialEq for EMinusMinus {
782 fn eq(&self, other: &Self) -> bool {
783 self.p1 == other.p1 && self.p2 == other.p2
784 }
785}
786
787impl Hash for EMinusMinus {
788 fn hash<H: Hasher>(&self, state: &mut H) {
789 self.p1.hash(state);
790 self.p2.hash(state);
791 }
792}
793
794impl PartialEq for Connective {
795 fn eq(&self, other: &Self) -> bool {
796 self.connective_instance == other.connective_instance
797 }
798}
799
800impl Hash for Connective {
801 fn hash<H: Hasher>(&self, state: &mut H) {
802 self.connective_instance.hash(state);
803 }
804}
805
806impl PartialEq for ConnectiveInstance {
807 fn eq(&self, other: &Self) -> bool {
808 match (self, other) {
809 (ConnectiveInstance::ConnAndBody(a), ConnectiveInstance::ConnAndBody(b)) => a == b,
810 (ConnectiveInstance::ConnOrBody(a), ConnectiveInstance::ConnOrBody(b)) => a == b,
811 (ConnectiveInstance::ConnNotBody(a), ConnectiveInstance::ConnNotBody(b)) => a == b,
812 (ConnectiveInstance::VarRefBody(a), ConnectiveInstance::VarRefBody(b)) => a == b,
813 (ConnectiveInstance::ConnBool(a), ConnectiveInstance::ConnBool(b)) => a == b,
814 (ConnectiveInstance::ConnInt(a), ConnectiveInstance::ConnInt(b)) => a == b,
815 (ConnectiveInstance::ConnString(a), ConnectiveInstance::ConnString(b)) => a == b,
816 (ConnectiveInstance::ConnUri(a), ConnectiveInstance::ConnUri(b)) => a == b,
817 (ConnectiveInstance::ConnByteArray(a), ConnectiveInstance::ConnByteArray(b)) => a == b,
818 _ => false,
819 }
820 }
821}
822
823impl Hash for ConnectiveInstance {
824 fn hash<H: Hasher>(&self, state: &mut H) {
825 match self {
826 ConnectiveInstance::ConnAndBody(a) => a.hash(state),
827 ConnectiveInstance::ConnOrBody(a) => a.hash(state),
828 ConnectiveInstance::ConnNotBody(a) => a.hash(state),
829 ConnectiveInstance::VarRefBody(a) => a.hash(state),
830 ConnectiveInstance::ConnBool(a) => a.hash(state),
831 ConnectiveInstance::ConnInt(a) => a.hash(state),
832 ConnectiveInstance::ConnString(a) => a.hash(state),
833 ConnectiveInstance::ConnUri(a) => a.hash(state),
834 ConnectiveInstance::ConnByteArray(a) => a.hash(state),
835 }
836 }
837}
838
839impl PartialEq for VarRef {
840 fn eq(&self, other: &Self) -> bool {
841 self.index == other.index && self.depth == other.depth
842 }
843}
844
845impl Hash for VarRef {
846 fn hash<H: Hasher>(&self, state: &mut H) {
847 self.index.hash(state);
848 self.depth.hash(state);
849 }
850}
851
852impl PartialEq for ConnectiveBody {
853 fn eq(&self, other: &Self) -> bool {
854 self.ps == other.ps
855 }
856}
857
858impl Hash for ConnectiveBody {
859 fn hash<H: Hasher>(&self, state: &mut H) {
860 self.ps.hash(state);
861 }
862}
863
864impl PartialEq for DeployId {
865 fn eq(&self, other: &Self) -> bool {
866 self.sig == other.sig
867 }
868}
869
870impl Hash for DeployId {
871 fn hash<H: Hasher>(&self, state: &mut H) {
872 self.sig.hash(state);
873 }
874}
875
876impl PartialEq for DeployerId {
877 fn eq(&self, other: &Self) -> bool {
878 self.public_key == other.public_key
879 }
880}
881
882impl Hash for DeployerId {
883 fn hash<H: Hasher>(&self, state: &mut H) {
884 self.public_key.hash(state);
885 }
886}
887
888impl PartialEq for GUnforgeable {
889 fn eq(&self, other: &Self) -> bool {
890 self.unf_instance == other.unf_instance
891 }
892}
893
894impl Hash for GUnforgeable {
895 fn hash<H: Hasher>(&self, state: &mut H) {
896 self.unf_instance.hash(state);
897 }
898}
899
900impl PartialEq for UnfInstance {
901 fn eq(&self, other: &Self) -> bool {
902 match (self, other) {
903 (UnfInstance::GPrivateBody(a), UnfInstance::GPrivateBody(b)) => a == b,
904 (UnfInstance::GDeployIdBody(a), UnfInstance::GDeployIdBody(b)) => a == b,
905 (UnfInstance::GDeployerIdBody(a), UnfInstance::GDeployerIdBody(b)) => a == b,
906 (UnfInstance::GSysAuthTokenBody(a), UnfInstance::GSysAuthTokenBody(b)) => a == b,
907 _ => false,
908 }
909 }
910}
911
912impl Hash for UnfInstance {
913 fn hash<H: Hasher>(&self, state: &mut H) {
914 match self {
915 UnfInstance::GPrivateBody(a) => a.hash(state),
916 UnfInstance::GDeployIdBody(a) => a.hash(state),
917 UnfInstance::GDeployerIdBody(a) => a.hash(state),
918 UnfInstance::GSysAuthTokenBody(a) => a.hash(state),
919 }
920 }
921}
922
923impl PartialEq for GPrivate {
924 fn eq(&self, other: &Self) -> bool {
925 self.id == other.id
926 }
927}
928
929impl Hash for GPrivate {
930 fn hash<H: Hasher>(&self, state: &mut H) {
931 self.id.hash(state);
932 }
933}
934
935impl PartialEq for GDeployId {
936 fn eq(&self, other: &Self) -> bool {
937 self.sig == other.sig
938 }
939}
940
941impl Hash for GDeployId {
942 fn hash<H: Hasher>(&self, state: &mut H) {
943 self.sig.hash(state);
944 }
945}
946
947impl PartialEq for GDeployerId {
948 fn eq(&self, other: &Self) -> bool {
949 self.public_key == other.public_key
950 }
951}
952
953impl Hash for GDeployerId {
954 fn hash<H: Hasher>(&self, state: &mut H) {
955 self.public_key.hash(state);
956 }
957}
958
959impl PartialEq for GSysAuthToken {
960 fn eq(&self, _other: &Self) -> bool {
961 true
962 }
963}
964
965impl Hash for GSysAuthToken {
966 fn hash<H: Hasher>(&self, _state: &mut H) {
967 }
969}
970
971impl fmt::Display for ServiceError {
972 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
973 write!(f, "ServiceError: {:#?}", self.messages)
974 }
975}
976
977impl Error for ServiceError {}