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

Method into_transactions

crates/commitlog/src/commit.rs:222–244  ·  view source on GitHub ↗

Convert `self` into an iterator yielding [`Transaction`]s. The supplied [`Decoder`] is responsible for extracting individual transactions from the `records` buffer. `version` is the log format version of the current segment, and gets passed to [`Decoder::decode_record`]. `from_offset` is the transaction offset within the current commit from which to start decoding. That is: if the tx offset wi

(
        self,
        version: u8,
        from_offset: u64,
        de: &D,
    )

Source from the content-addressed store, hash-verified

220 /// yields nothing.
221 ///
222 pub fn into_transactions<D: Decoder>(
223 self,
224 version: u8,
225 from_offset: u64,
226 de: &D,
227 ) -> impl Iterator<Item = Result<Transaction<D::Record>, D::Error>> + '_ {
228 let records = Cursor::new(self.records);
229 (self.min_tx_offset..(self.min_tx_offset + self.n as u64))
230 .scan(records, move |recs, offset| {
231 let mut cursor = &*recs;
232 let ret = if offset < from_offset {
233 de.skip_record(version, offset, &mut cursor).err().map(Err)
234 } else {
235 let tx = de
236 .decode_record(version, offset, &mut cursor)
237 .map(|txdata| Transaction { offset, txdata });
238 Some(tx)
239 };
240
241 Some(ret)
242 })
243 .flatten()
244 }
245}
246
247impl From<StoredCommit> for Commit {

Callers 3

transactionsMethod · 0.80

Calls 6

flattenMethod · 0.80
errMethod · 0.80
newFunction · 0.50
mapMethod · 0.45
skip_recordMethod · 0.45
decode_recordMethod · 0.45

Tested by 1