Variant of [`Self::decode`] which doesn't allocate `Self`. Useful for folding traversals where the visitor state suffices. Note that both [`Inputs`] and [`Outputs`] are still allocated to satisfy the [`Visitor`] trait, but [`Mutations`] aren't.
(visitor: &mut V, reader: &mut R)
| 184 | /// Note that both [`Inputs`] and [`Outputs`] are still allocated to satisfy |
| 185 | /// the [`Visitor`] trait, but [`Mutations`] aren't. |
| 186 | pub fn consume<'a, V, R>(visitor: &mut V, reader: &mut R) -> Result<(), V::Error> |
| 187 | where |
| 188 | V: Visitor<Row = T>, |
| 189 | R: BufReader<'a>, |
| 190 | { |
| 191 | let flags = Flags::from_bits_retain(reader.get_u8()?); |
| 192 | |
| 193 | // If the flags indicate that the payload contains `Inputs`, |
| 194 | // try to decode and visit them. |
| 195 | if flags.contains(Flags::HAVE_INPUTS) { |
| 196 | let inputs = Inputs::decode(reader)?; |
| 197 | visitor.visit_inputs(&inputs)?; |
| 198 | } |
| 199 | |
| 200 | // If the flags indicate that the payload contains `Outputs`, |
| 201 | // try to decode and visit them. |
| 202 | if flags.contains(Flags::HAVE_OUTPUTS) { |
| 203 | let outputs = Outputs::decode(reader)?; |
| 204 | visitor.visit_outputs(&outputs)?; |
| 205 | } |
| 206 | |
| 207 | // If the flags indicate that the payload contains `Mutations`, |
| 208 | // try to consume them (i.e. decode but don't allocate). |
| 209 | if flags.contains(Flags::HAVE_MUTATIONS) { |
| 210 | Mutations::consume(visitor, reader)?; |
| 211 | } |
| 212 | |
| 213 | Ok(()) |
| 214 | } |
| 215 | |
| 216 | pub fn skip<'a, V, R>(visitor: &mut V, reader: &mut R) -> Result<(), V::Error> |
| 217 | where |
no test coverage detected