macroonz_compiler/support/carrier/
encode.rs1use super::ShellError;
3use crate::identity::{encode_bytes, encode_length};
4impl ShellError {
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::NotOneDeclaration { stated, planned } => {
17 encode_bytes(stated.as_bytes(), into);
18 encode_bytes(planned.as_bytes(), into);
19 }
20 Self::TreeUnbounded { bound, observed } => {
21 encode_length(*bound, into);
22 encode_length(*observed, into);
23 }
24 }
25 }
26}