GorillaStream.Compression.Encoder.BitWriter (gorilla_stream v3.0.3)

Copy Markdown View Source

Utility module for incrementally building a bitstring using iodata. It accumulates bits in a buffer and flushes complete bytes to an iolist, preserving performance while allowing non-byte-aligned final output.

Summary

Functions

Convert the accumulated bits to a binary. Any remaining bits fewer than a byte are appended at the end without padding.

Write size bits from value into the writer.

Write the given bits bitstring into the writer.

Types

t()

@type t() :: %GorillaStream.Compression.Encoder.BitWriter{
  acc: iodata(),
  bits: non_neg_integer(),
  buf: non_neg_integer()
}

Functions

to_binary(bit_writer)

@spec to_binary(t()) :: bitstring()

Convert the accumulated bits to a binary. Any remaining bits fewer than a byte are appended at the end without padding.

write(w, value, size)

@spec write(t(), non_neg_integer(), non_neg_integer()) :: t()

Write size bits from value into the writer.

write_bits(w, bits)

@spec write_bits(t(), bitstring()) :: t()

Write the given bits bitstring into the writer.