Returns the value at the given index Useful if we want to know what value has been inserted to the builder The index has to be smaller than `self.len()`, otherwise it will panic
(&self, index: usize)
| 299 | /// Useful if we want to know what value has been inserted to the builder |
| 300 | /// The index has to be smaller than `self.len()`, otherwise it will panic |
| 301 | pub fn get_value(&self, index: usize) -> &[u8] { |
| 302 | let view = self.views_buffer.as_slice().get(index).unwrap(); |
| 303 | let len = *view as u32; |
| 304 | if len <= MAX_INLINE_VIEW_LEN { |
| 305 | // # Safety |
| 306 | // The view is valid from the builder |
| 307 | unsafe { GenericByteViewArray::<T>::inline_value(view, len as usize) } |
| 308 | } else { |
| 309 | let view = ByteView::from(*view); |
| 310 | if view.buffer_index < self.completed.len() as u32 { |
| 311 | let block = &self.completed[view.buffer_index as usize]; |
| 312 | &block[view.offset as usize..view.offset as usize + view.length as usize] |
| 313 | } else { |
| 314 | &self.in_progress[view.offset as usize..view.offset as usize + view.length as usize] |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | /// Appends a value into the builder |
| 320 | /// |
no test coverage detected