MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / byte_sequence

Method byte_sequence

atomic-core/examples/graph_codec_lab/codec.rs:148–173  ·  view source on GitHub ↗
(&mut self, bytes: &[u8])

Source from the content-addressed store, hash-verified

146 Ok(())
147 }
148 fn byte_sequence(&mut self, bytes: &[u8]) -> SResult<()> {
149 if self.sequential
150 && self.c.content_hash.is_some()
151 && self
152 .authored
153 .get(self.source_cursor..)
154 .is_some_and(|rest| rest.starts_with(bytes))
155 {
156 let length = self.column(6, bytes.len() as u64)?;
157 self.c.control.push(21);
158 put(&mut self.c.control, length as u64);
159 self.source_cursor += bytes.len();
160 return Ok(());
161 }
162 if let Some(&offset) = self.content_lookup.get(bytes) {
163 let a = self.column(5, offset as u64)?;
164 let b = self.column(6, bytes.len() as u64)?;
165 self.c.control.push(20);
166 put(&mut self.c.control, a as u64);
167 put(&mut self.c.control, b as u64);
168 self.source_cursor = offset + bytes.len();
169 Ok(())
170 } else {
171 self.reference(bytes, 18)
172 }
173 }
174 fn small_number(&mut self, kind: u8, n: u64) -> SResult<()> {
175 if n < 16 {
176 self.c.control.push(n as u8);

Callers 3

finishMethod · 0.80
serialize_strMethod · 0.80
serialize_bytesMethod · 0.80

Calls 6

columnMethod · 0.80
putFunction · 0.70
getMethod · 0.65
lenMethod · 0.45
pushMethod · 0.45
referenceMethod · 0.45

Tested by

no test coverage detected