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

Method copy

atomic-repository/src/changestore/mod.rs:145–155  ·  view source on GitHub ↗

The bytes of `start..end` in `hash`'s content, if one held span covers them.

(&self, hash: &Hash, start: usize, end: usize, buf: &mut [u8])

Source from the content-addressed store, hash-verified

143impl SpanOverlay {
144 /// The bytes of `start..end` in `hash`'s content, if one held span covers them.
145 fn copy(&self, hash: &Hash, start: usize, end: usize, buf: &mut [u8]) -> Option<usize> {
146 let (&(h, s), (e, bytes)) = self.spans.range(..=(*hash, start as u64)).next_back()?;
147 if h != *hash || (end as u64) > *e {
148 return None;
149 }
150 let from = start - s as usize;
151 let len = end - start;
152 buf.get_mut(..len)?
153 .copy_from_slice(bytes.get(from..from + len)?);
154 Some(len)
155 }
156}
157
158impl std::fmt::Debug for ChangeStore {

Callers 5

__init__Method · 0.80
setUpMethod · 0.80
shellMethod · 0.80
copy_content_spanMethod · 0.80

Calls 3

rangeMethod · 0.80
get_mutMethod · 0.80
getMethod · 0.65

Tested by 3

setUpMethod · 0.64
shellMethod · 0.64