Struct BitReader
Helper class for doing bitwise reads for a FastBufferReader. Ensures all bitwise reads end on proper byte alignment so FastBufferReader doesn't have to be concerned with misaligned reads.
Inherited Members
Namespace: Unity.Netcode
Assembly: solution.dll
Syntax
public ref struct BitReader
Properties
Name | Description |
---|---|
BitAligned | Whether or not the current BitPosition is evenly divisible by 8. I.e. whether or not the BitPosition is at a byte boundary. |
Methods
Name | Description |
---|---|
Dispose() | Pads the read bit count to byte alignment and commits the read back to the reader |
ReadBit(out bool) | Read a single bit from the buffer |
ReadBits(out byte, uint) | Read bits from stream. |
ReadBits(out ulong, uint) | Read a certain amount of bits from the stream. |
TryBeginReadBits(uint) | Verifies the requested bit count can be read from the buffer. This exists as a separate method to allow multiple bit reads to be bounds checked with a single call. If it returns false, you may not read, and in editor and development builds, attempting to do so will throw an exception. In release builds, attempting to do so will read junk memory. |