MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / append_framed

Method append_framed

nodedb-array/src/segment/writer.rs:49–80  ·  view source on GitHub ↗
(
        &mut self,
        tile_id: TileId,
        kind: TileKind,
        payload: &[u8],
        mbr: crate::tile::mbr::TileMBR,
    )

Source from the content-addressed store, hash-verified

47 }
48
49 fn append_framed(
50 &mut self,
51 tile_id: TileId,
52 kind: TileKind,
53 payload: &[u8],
54 mbr: crate::tile::mbr::TileMBR,
55 ) -> ArrayResult<()> {
56 if let Some(last) = self.entries.last()
57 && tile_id <= last.tile_id
58 {
59 return Err(ArrayError::SegmentCorruption {
60 detail: format!(
61 "tile IDs not strictly monotonic ascending: \
62 prev=({},{}) new=({},{})",
63 last.tile_id.hilbert_prefix,
64 last.tile_id.system_from_ms,
65 tile_id.hilbert_prefix,
66 tile_id.system_from_ms,
67 ),
68 });
69 }
70 let offset = self.buf.len() as u64;
71 let framed_len = BlockFraming::encode(payload, &mut self.buf);
72 self.entries.push(TileEntry::new(
73 tile_id,
74 kind,
75 offset,
76 framed_len as u32,
77 mbr,
78 ));
79 Ok(())
80 }
81
82 pub fn tile_count(&self) -> usize {
83 self.entries.len()

Callers 2

append_sparseMethod · 0.80
append_denseMethod · 0.80

Calls 4

encodeFunction · 0.50
lastMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected