MCPcopy Index your code
hub / github.com/Workiva/go-datastructures / Deserialize

Method Deserialize

bitarray/encoding.go:200–234  ·  view source on GitHub ↗

Deserialize takes the incoming byte slice, and populates the bitArray with data in the bytes. Note that this will overwrite any capacity specified when creating the bitArray. Also note that if an error is returned, the bitArray this is called on might be populated with partial data.

(incoming []byte)

Source from the content-addressed store, hash-verified

198// specified when creating the bitArray. Also note that if an error is returned,
199// the bitArray this is called on might be populated with partial data.
200func (ret *bitArray) Deserialize(incoming []byte) error {
201 r := bytes.NewReader(incoming[1:]) // Discard identifier
202
203 err := binary.Read(r, binary.LittleEndian, &ret.lowest)
204 if err != nil {
205 return err
206 }
207
208 err = binary.Read(r, binary.LittleEndian, &ret.highest)
209 if err != nil {
210 return err
211 }
212
213 var encodedanyset uint8
214 err = binary.Read(r, binary.LittleEndian, &encodedanyset)
215 if err != nil {
216 return err
217 }
218
219 // anyset defaults to false so we don't need an else statement
220 if encodedanyset == 1 {
221 ret.anyset = true
222 }
223
224 var nextblock block
225 err = binary.Read(r, binary.LittleEndian, &nextblock)
226 for err == nil {
227 ret.blocks = append(ret.blocks, nextblock)
228 err = binary.Read(r, binary.LittleEndian, &nextblock)
229 }
230 if err != io.EOF {
231 return err
232 }
233 return nil
234}

Callers 3

UnmarshalFunction · 0.45

Calls

no outgoing calls

Tested by 2