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,
)
| 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 | |
| 247 | impl From<StoredCommit> for Commit { |