Skip to content
FutureBlitz

    Install

    Import std.compress.stream

    CoderWriter

    std.compress.stream

    class

    Public Class CoderWriter Implements Writer

    A Writer whose bytes go through a Coder to another Writer: Write adds them to the Coder and writes what comes of them, and Finish writes the rest, which ends what the Coder makes, as CoderWriter(file, GzipCompressor()) ends a gzip member. A Coder holds on to what it hasn't coded, so Flush flushes only the other Writer, and the Coder's rest comes with Finish. Each throws the IOError the Coder or the Writer does.

    Examples

    Local memory = MemoryStream()
    Local writer = CoderWriter(memory, GzipCompressor())
    Try writer.WriteText("written a part at a time")
    Try writer.Finish()
    Expect(String.FromUtf8(Try Gzip.Decompress(memory.ToArray())) == "written a part at a time")

    std/compress/stream.fb, line 33

    • Public New(inner: Writer, through: Coder) constructor #

      A CoderWriter that writes to inner what through makes of the bytes it's given.

    • Public Method Write(from: Buffer<UInt8>) Throws IOError method #

      Puts the bytes through the Coder, and writes what comes of them so far to the other Writer.

    • Public Method Flush() Throws IOError method #

      Flushes the other Writer, but not the Coder, whose rest comes with Finish.

    • Public Method Finish() Throws IOError method #

      Writes what the Coder has left, and flushes the other Writer. The Coder starts again, so what's written next is coded on its own, as a gzip's next member is.

    Report an issue with this page or with FutureBlitz on GitHub.