Expand description
MSB-first bit cursor over a byte slice.
CCSDS packets are bit-packed big-endian: a field starts at an arbitrary bit offset and
runs most-significant bit first, straddling byte boundaries freely. Everything the
decoder reads goes through BitCursor.
§The 9-byte case
A 64-bit field at a non-zero bit offset spans nine bytes. The obvious implementation
— load eight bytes and shift — silently truncates it. Every read here goes through a
u128 accumulator, which covers the widest possible span (7 offset bits + 64 width) with
room to spare. The property tests deliberately generate that case.
§No panics
Every out-of-range read returns BitError. A corrupt or hostile packet must never
bring down a decoder that is processing a live downlink.
Structs§
- BitCursor
- A big-endian, MSB-first bit reader.
Enums§
- BitError
- Reading past the end of the data, or asking for more bits than fit in the result.
Functions§
- ones_
complement - Reinterprets an unsigned field as ones’ complement.
- sign_
magnitude - Reinterprets an unsigned field as sign-magnitude: top bit is the sign, rest the magnitude.
- swap_
byte_ order - Reverses the byte order of a field, for
leastSignificantByteFirstencodings. - twos_
complement - Reinterprets an unsigned field of
widthbits as a signed integer. - twos_
complement_ unmasked - Sign extension for the one case where the value can be wider than the field it came from.