Expand description
Joins brotli streams that were compressed to be concatenated (-appendable for the first
stream, -catable for the rest) into one stream.
A brotli stream is a sequence of bits, least significant bit first: a window size, then meta-blocks. It ends with an empty meta-block, which is just the two bits ISLAST and ISLASTEMPTY, followed by zero padding to the end of the byte. A catable stream starts with a meta-block whose header leaves the stream byte aligned (an uncompressed or metadata meta-block, or the streamβs final empty one), and it never refers back to data before itself.
So appending stream B to output A only takes changing a few bits where they meet:
A: ... | ISLAST ISLASTEMPTY | padding
B: window size | header | padding | aligned bytes ...
A then B: ... | header | padding | aligned bytes ...Aβs ISLAST/ISLASTEMPTY pair always lies in its last two bytes, so BroCatli holds the last two
bytes of the output back (the tail) until it knows whether another stream follows, and copies
everything else straight through.
StructsΒ§
- BitReader π
- Reads bits from the buffered start of a stream.
- BitWriter π
- Assembles bits into bytes, least significant bit first.
- BroCatli
- ByteBuf π
- A few buffered bytes.
EnumsΒ§
- BroCatli
Result - Parse
Error π - Phase π
ConstantsΒ§
- FLAG_
ANY_ πBYTES_ EMITTED - FLAG_
NEW_ πSTREAM - FLAG_
OPEN_ πTAIL - FLAG_
TRUNCATED π - FLAG_
WRITE_ πSPLICE - NUM_
STREAM_ πHEADER_ BYTES - How many bytes of a new stream are buffered to find where it becomes byte aligned.
FunctionsΒ§
- bit_
range π - The value of bits
start..endofbytes, least significant bit first. - max_
header_ πbytes - The most bytes of a new stream that are read before giving up on finding where it becomes byte aligned: 4, or 5 for a large window size. That fits an uncompressed first meta-block of up to 1 MiB (five length nibbles), or metadata with up to two length bytes.
- remove_
final_ πempty_ metablock - Splits the final bytes of a stream into the bits before its closing ISLAST + ISLASTEMPTY pair,
returning them with their count, or
Noneif the bytes donβt end that way.