(
hash: &Hash,
change: &Change,
start: usize,
end: usize,
buf: &mut [u8],
)
| 134 | } |
| 135 | |
| 136 | fn copy_content_from_change( |
| 137 | hash: &Hash, |
| 138 | change: &Change, |
| 139 | start: usize, |
| 140 | end: usize, |
| 141 | buf: &mut [u8], |
| 142 | ) -> ChangeStoreResult<usize> { |
| 143 | if end > change.contents.len() { |
| 144 | return Err(ChangeStoreError::ContentOutOfBounds { |
| 145 | hash: hash.to_base32(), |
| 146 | requested_start: start, |
| 147 | requested_end: end, |
| 148 | content_len: change.contents.len(), |
| 149 | }); |
| 150 | } |
| 151 | |
| 152 | let len = end - start; |
| 153 | if buf.len() < len { |
| 154 | return Err(ChangeStoreError::ContentOutOfBounds { |
| 155 | hash: hash.to_base32(), |
| 156 | requested_start: start, |
| 157 | requested_end: end, |
| 158 | content_len: buf.len(), |
| 159 | }); |
| 160 | } |
| 161 | |
| 162 | buf[..len].copy_from_slice(&change.contents[start..end]); |
| 163 | Ok(len) |
| 164 | } |
| 165 | |
| 166 | impl ChangeStore { |
| 167 | /// Create a new change store with the given directory and cache capacity. |
no test coverage detected