(
bufman: &BufferManager,
FileOffset(offset): FileOffset,
)
| 65 | } |
| 66 | |
| 67 | fn deserialize( |
| 68 | bufman: &BufferManager, |
| 69 | FileOffset(offset): FileOffset, |
| 70 | ) -> Result<Self, BufIoError> { |
| 71 | let cursor = bufman.open_cursor()?; |
| 72 | bufman.seek_with_cursor(cursor, offset as u64)?; |
| 73 | |
| 74 | let variant_index = bufman.read_u8_with_cursor(cursor)?; |
| 75 | |
| 76 | let storage = match variant_index { |
| 77 | 0 => { |
| 78 | let mag = bufman.read_f32_with_cursor(cursor)?; |
| 79 | let len = bufman.read_u32_with_cursor(cursor)? as usize; |
| 80 | let mut quant_vec = Vec::with_capacity(len); |
| 81 | |
| 82 | for _ in 0..len { |
| 83 | let el = bufman.read_u8_with_cursor(cursor)?; |
| 84 | quant_vec.push(el); |
| 85 | } |
| 86 | |
| 87 | Self::UnsignedByte { mag, quant_vec } |
| 88 | } |
| 89 | 1 => { |
| 90 | let resolution = bufman.read_u8_with_cursor(cursor)?; |
| 91 | let mag = bufman.read_f32_with_cursor(cursor)?; |
| 92 | let len = bufman.read_u32_with_cursor(cursor)? as usize; |
| 93 | let mut quant_vec = Vec::with_capacity(len); |
| 94 | |
| 95 | for _ in 0..len { |
| 96 | let len = bufman.read_u32_with_cursor(cursor)? as usize; |
| 97 | let mut vec = Vec::with_capacity(len); |
| 98 | for _ in 0..len { |
| 99 | let el = bufman.read_u8_with_cursor(cursor)?; |
| 100 | vec.push(el); |
| 101 | } |
| 102 | quant_vec.push(vec); |
| 103 | } |
| 104 | |
| 105 | Self::SubByte { |
| 106 | mag, |
| 107 | quant_vec, |
| 108 | resolution, |
| 109 | } |
| 110 | } |
| 111 | 2 => { |
| 112 | let mag = bufman.read_f32_with_cursor(cursor)?; |
| 113 | let len = bufman.read_u32_with_cursor(cursor)? as usize; |
| 114 | let mut quant_vec = Vec::with_capacity(len); |
| 115 | |
| 116 | for _ in 0..len { |
| 117 | let mut bytes = [0; 2]; |
| 118 | bufman.read_with_cursor(cursor, &mut bytes)?; |
| 119 | let el = f16::from_le_bytes(bytes); |
| 120 | quant_vec.push(el); |
| 121 | } |
| 122 | |
| 123 | Self::HalfPrecisionFP { mag, quant_vec } |
| 124 | } |
nothing calls this directly
no test coverage detected