ChunkedBuffer #
This module provides an efficient way to concatenate multiple ByteArrays by deferring the actual
concatenation until necessary. This is particularly useful in HTTP response building and streaming
scenarios where data is accumulated incrementally.
@[inline]
Writes a ByteArray to the ChunkedBuffer.
Instances For
@[inline]
Writes a Char to the ChunkedBuffer. Only the low byte is written (Char.toUInt8),
so this is only correct for ASCII characters.
Instances For
@[inline]
Writes a String to the ChunkedBuffer.
Equations
- buffer.writeString data = buffer.push data.toUTF8
Instances For
@[inline]
Turn the combined structure into a single contiguous ByteArray.
Equations
- cb.toByteArray = if h : 1 = cb.data.size then cb.data[0] else Array.foldl (fun (x1 x2 : ByteArray) => x1 ++ x2) (ByteArray.emptyWithCapacity cb.size) cb.data
Instances For
@[inline]
Build from a ByteArray directly.
Instances For
@[inline]
Build from an array of ByteArrays directly.
Equations
- Std.Http.Internal.ChunkedBuffer.ofArray bs = { data := bs, size := Array.foldl (fun (x1 : Nat) (x2 : ByteArray) => x1 + x2.size) 0 bs }
Instances For
@[inline]
Checks whether the buffer is empty.
Instances For
@[implicit_reducible]
Equations
@[implicit_reducible]
Equations
- Std.Http.Internal.ChunkedBuffer.instEmptyCollection = { emptyCollection := Std.Http.Internal.ChunkedBuffer.empty }
@[implicit_reducible]
@[implicit_reducible]