Return the next bit from the buffer
()
| 168 | |
| 169 | // Return the next bit from the buffer |
| 170 | func (p *BitReader) ReadBit() (byte, error) { |
| 171 | if p.BitsLeft() == 0 { |
| 172 | return 0, fmt.Errorf("Not enough bits left to read") |
| 173 | } |
| 174 | r := (p.currentByte & netmasks[p.posInCurrentByte]) >> p.posInCurrentByte |
| 175 | p.SkipBits(1) |
| 176 | return r, nil |
| 177 | } |
| 178 | |
| 179 | // Return n number of bytes read from the buffer |
| 180 | func (p *BitReader) ReadBytes(n uint) ([]byte, error) { |