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

Method reference

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

Source from the content-addressed store, hash-verified

180 }
181 }
182 fn reference(&mut self, bytes: &[u8], tag: u8) -> SResult<()> {
183 let next = self.c.dictionary.len();
184 let id = if let Some(&id) = self.dictionary.get(bytes) {
185 id
186 } else {
187 self.dictionary.insert(bytes.to_vec(), next);
188 self.c.dictionary.push(bytes.to_vec());
189 next
190 };
191 self.c.control.push(tag);
192 delta(&mut self.c.references, &mut self.last_reference, id as u64);
193 Ok(())
194 }
195 fn raw<T: Serialize>(&mut self, value: &T) -> SResult<()> {
196 let bytes = postcard::to_allocvec(value).map_err(|e| Error(e.to_string()))?;
197 self.reference(&bytes, 19)

Calls 5

deltaFunction · 0.70
getMethod · 0.65
lenMethod · 0.45
insertMethod · 0.45
pushMethod · 0.45