/// <summary> /// Reads 1 to 8 bits into a <see cref="byte"/>. /// </summary> /// <exception cref="EndOfMessageException"></exception> public static byte ReadByte(this IBitBuffer buffer, int bitCount) { if (!buffer.ReadByte(bitCount, out byte value)) { throw new EndOfMessageException(); } return(value); }
/// <summary> /// Reads a 1-bit <see cref="bool"/>. /// </summary> public static bool ReadBit(this IBitBuffer buffer, out bool result) { if (!buffer.ReadByte(1, out byte value)) { result = default; return(false); } result = value > 0; return(true); }