macroonz_compiler/support/assembly/
encode.rs1use super::AssemblyIssue;
3use crate::identity::encode_bytes;
4impl AssemblyIssue {
5 #[must_use]
7 pub fn canonical_bytes(&self) -> Vec<u8> {
8 let mut bytes = Vec::new();
9 self.encode_into(&mut bytes);
10 bytes
11 }
12 pub fn encode_into(&self, into: &mut Vec<u8>) {
14 into.push(self.slot());
15 match self {
16 Self::RootsDisagree {
17 axis,
18 stated,
19 carried,
20 } => {
21 encode_bytes(axis.name().as_bytes(), into);
22 encode_bytes(stated.as_bytes(), into);
23 encode_bytes(carried.as_bytes(), into);
24 }
25 Self::CargoConsumedTwice {
26 source,
27 destination,
28 }
29 | Self::CargoNotTheSourcesOwn {
30 source,
31 destination,
32 } => {
33 encode_bytes(source.as_bytes(), into);
34 encode_bytes(destination.name().as_bytes(), into);
35 }
36 Self::CargoReachesASecondDestination { axis, destination } => {
37 encode_bytes(axis.name().as_bytes(), into);
38 encode_bytes(destination.name().as_bytes(), into);
39 }
40 Self::DeclaredAxisRequiresStampedCargo | Self::TwoFormsCarried => {}
41 Self::StampedCargoAbsent { form } => encode_bytes(form.name().as_bytes(), into),
42 }
43 }
44}