class OutputStreamBitChannel implements BitChannel, Closeable {

    public void write(boolean value) throws IOException {
        if (value) {
            buffer = (byte) (0xff & ((buffer << 1) | 0x01));
        } else {
            buffer = (byte) (0xff & (buffer << 1));
        }
        if (++bitPos == 8) {
            bitPos = 0;
            out.write(buffer);
            buffer = 0;
        }
    }

    public  OutputStreamBitChannel(@Nonnull OutputStream out);

}