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

Method decode_v0

crates/commitlog/src/commit.rs:58–82  ·  view source on GitHub ↗
(mut reader: R)

Source from the content-addressed store, hash-verified

56 }
57
58 fn decode_v0<R: Read>(mut reader: R) -> io::Result<Option<Self>> {
59 let mut hdr = [0; Self::LEN - 8];
60 if let Err(e) = reader.read_exact(&mut hdr) {
61 if e.kind() == io::ErrorKind::UnexpectedEof {
62 return Ok(None);
63 }
64
65 return Err(e);
66 }
67 match &mut hdr.as_slice() {
68 [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] => Ok(None),
69 buf => {
70 let min_tx_offset = buf.get_u64().map_err(|e| decode_header_error(e, "min_tx_offset"))?;
71 let n = buf.get_u16().map_err(|e| decode_header_error(e, "n"))?;
72 let len = buf.get_u32().map_err(|e| decode_header_error(e, "len"))?;
73
74 Ok(Some(Self {
75 min_tx_offset,
76 epoch: Commit::DEFAULT_EPOCH,
77 n,
78 len,
79 }))
80 }
81 }
82 }
83
84 fn decode_v1<R: Read>(mut reader: R) -> io::Result<Option<Self>> {
85 let mut hdr = [0; Self::LEN];

Callers

nothing calls this directly

Calls 7

decode_header_errorFunction · 0.85
get_u64Method · 0.80
get_u16Method · 0.80
get_u32Method · 0.80
OkFunction · 0.50
ErrFunction · 0.50
kindMethod · 0.45

Tested by

no test coverage detected