bitstreams

Interface for reading per bits

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install bitstreams
choosenim install bitstreams
git clone https://github.com/sealmove/bitstreams

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
bitstreams - - - - - - -

Source

Repository https://github.com/sealmove/bitstreams
Homepage https://github.com/sealmove/bitstreams
Registry Source nimble_official

README

bitstreams

Interface for reading/writing per bits

How it works

This module is a wrapper around stdlib's streams module.

type
  BitStream* = ref object
    stream: Stream
    buffer: uint64
    bitsLeft: int

bitsLeft keeps track of how many bits in buffer are not read by the end-user, then: - if they are more than the user requests, then no real read happens on steam - if they are less than the user requests, data are read from stream into buffer

Constructor & Modes

Two constructors are provided:

proc newFileBitStream*(f: string; mode = fmRead; size = -1): BitStream
proc newStringBitStream*(s = ""): BitStream

fmWrite and fmAppend are disallowed because when writing to a bitstream, reads on the underlying Stream object are necessary.