| 119 | pub const VERSION: u8 = DEFAULT_LOG_FORMAT_VERSION; |
| 120 | |
| 121 | pub fn encode(&self, buf: &mut impl BufWriter) { |
| 122 | let mut flags = Flags::empty(); |
| 123 | flags.set(Flags::HAVE_INPUTS, self.inputs.is_some()); |
| 124 | flags.set(Flags::HAVE_OUTPUTS, self.outputs.is_some()); |
| 125 | flags.set(Flags::HAVE_MUTATIONS, self.mutations.is_some()); |
| 126 | |
| 127 | buf.put_u8(flags.bits()); |
| 128 | if let Some(inputs) = &self.inputs { |
| 129 | inputs.encode(buf); |
| 130 | } |
| 131 | if let Some(outputs) = &self.outputs { |
| 132 | outputs.encode(buf); |
| 133 | } |
| 134 | if let Some(mutations) = &self.mutations { |
| 135 | mutations.encode(buf) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /// Decode `Self` from the given buffer. |
| 140 | pub fn decode<'a, V, R>(visitor: &mut V, reader: &mut R) -> Result<Self, V::Error> |