MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / consume

Method consume

crates/commitlog/src/payload/txdata.rs:186–214  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

append_allMethod · 0.45

Calls 12

decodeFunction · 0.85
decode_varintFunction · 0.85
get_u8Method · 0.80
visit_outputsMethod · 0.80
get_u32Method · 0.80
OkFunction · 0.50
containsMethod · 0.45
visit_inputsMethod · 0.45
mapMethod · 0.45
visit_insertMethod · 0.45
visit_deleteMethod · 0.45
visit_truncateMethod · 0.45

Tested by

no test coverage detected