Skip to content
FutureBlitz

    Install

    Import std.compress.stream

    std.compress.stream

    std.compress over std.io's streams: a CoderWriter writes what's written to it through a Coder, like a GzipCompressor, to another Writer, and a CoderReader reads what another Reader gives through one, like a GzipDecompressor, so a file or a socket compresses and decompresses as it goes, a part at a time.

    std/compress/stream.fb

    Types

    CoderWriter 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 yet, 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.

    std/compress/stream.fb, line 19

    • 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 #

      Writes all of from's bytes, in order.

      Doc from std.io.streams.Writer.Write.

    • Public Method Flush() Throws IOError method #

      Sends on what it holds on to, to what it writes to. One that holds nothing does nothing.

      Doc from std.io.streams.Writer.Flush.

    • 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.

    CoderReader class

    Public Class CoderReader Implements Reader

    A Reader whose bytes are what another Reader's come to through a Coder, as CoderReader(file, GzipDecompressor()) reads a .gz file's: it reads the other Reader a chunk at a time, and once that ends, gives what the Coder has left, and then ends. Read throws the IOError the Coder or the Reader does, like a Decompressor's for bytes that aren't its format, or that end too soon, and a Read after that throws again, or ends.

    std/compress/stream.fb, line 52

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

      A CoderReader that reads what through makes of what inner gives.

    • Public Method Read(into: Buffer<UInt8>): Int64 Throws IOError method #

      Reads up to into.Count bytes into the start of into, and gives how many it read: one at least, or 0 once the stream has ended, or for an empty Buffer.

      Doc from std.io.streams.Reader.Read.

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