| 76 | /// Sentinel for `None` in the preprocessed-index trailer. |
| 77 | const NO_PREP_INDEX: u16 = u16::MAX; |
| 78 | |
| 79 | // ════════════════════════════════════════════════════════════════════════════ |
| 80 | // Encoder — System<AiurConfig> -> bytes |
| 81 | // ════════════════════════════════════════════════════════════════════════════ |
| 82 | |
| 83 | fn push_u16(buf: &mut Vec<u8>, v: usize) { |
| 84 | let v = u16::try_from(v).expect("vk header field exceeds u16"); |
| 85 | buf.extend_from_slice(&v.to_le_bytes()); |
| 86 | } |
| 87 | |
| 88 | fn push_u32(buf: &mut Vec<u8>, v: usize) { |
| 89 | let v = u32::try_from(v).expect("vk field exceeds u32"); |
| 90 | buf.extend_from_slice(&v.to_le_bytes()); |
| 91 | } |
| 92 | |
| 93 | /// Node ids on the wire are u16: per-circuit graphs are far below 65k |
| 94 | /// nodes (the whole kernel system is ~140k across 800+ circuits). |
| 95 | fn push_node_id(buf: &mut Vec<u8>, id: NodeId) { |
| 96 | let id = u16::try_from(id.0).expect("node id exceeds u16 (vk wire format)"); |
| 97 | buf.extend_from_slice(&id.to_le_bytes()); |
| 98 | } |
| 99 | |