io

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package io provides the implementations of a Writer and a Reader used to respectively losslessly compress and decompress data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IOError

type IOError struct {
	// contains filtered or unexported fields
}

IOError an extended error containing a message and a code value

func (IOError) Error

func (this IOError) Error() string

Error returns the underlying error

func (IOError) ErrorCode

func (this IOError) ErrorCode() int

ErrorCode returns the code value associated with the error

func (IOError) Message

func (this IOError) Message() string

Message returns the message string associated with the error

type NullOutputStream

type NullOutputStream struct {
	// contains filtered or unexported fields
}

NullOutputStream similar to io.Discard but implements io.WriteCloser

func NewNullOutputStream

func NewNullOutputStream() (*NullOutputStream, error)

NewNullOutputStream creates an instance of NullOutputStream

func (*NullOutputStream) Close

func (this *NullOutputStream) Close() error

Close makes the stream unavailable for future writes

func (*NullOutputStream) Write

func (this *NullOutputStream) Write(b []byte) (n int, err error)

Write returns an error if the stream is closed else does nothing.

type Reader added in v2.3.0

type Reader struct {
	// contains filtered or unexported fields
}

Reader a Reader that reads compressed data from an InputBitStream.

func NewHeaderlessReader added in v2.3.0

func NewHeaderlessReader(is io.ReadCloser, jobs uint, transform, entropy string, blockSize uint, checksum bool, originalSize int64, bsVersion uint) (*Reader, error)

NewHeaderlessReader creates a new instance of Reader to decompress a headerless bitstream. The reader reads compressed data blocks from the provided is. Use 0 if the original file size is not known. The default value for the bitstream version is _BITSTREAM_FORMAT_VERSION. If the provided compression parameters do not match those used during compression, the decompression is likely to fail.

func NewReader added in v2.3.0

func NewReader(is io.ReadCloser, jobs uint) (*Reader, error)

NewReader creates a new instance of Reader. The reader reads compressed data blocks from the provided is.

func NewReaderWithCtx added in v2.3.0

func NewReaderWithCtx(is io.ReadCloser, ctx map[string]any) (*Reader, error)

NewReaderWithCtx creates a new instance of Reader using a map of parameters. The reader reads compressed data blocks from the provided is using a default input bitstream.

func NewReaderWithCtx2 added in v2.3.0

func NewReaderWithCtx2(ibs kanzi.InputBitStream, ctx map[string]any) (*Reader, error)

NewReaderWithCtx2 creates a new instance of Reader. using a map of parameters and a custom input bitstream. The reader reads compressed data blocks from the provided input bitstream.

func (*Reader) AddListener added in v2.3.0

func (this *Reader) AddListener(bl kanzi.Listener) bool

AddListener adds an event listener to this reader. Returns true if the listener has been added.

func (*Reader) Close added in v2.3.0

func (this *Reader) Close() error

Close reads the buffered data from the reader and releases resources. Close makes the bitstream unavailable for further reads. Idempotent

func (*Reader) GetRead added in v2.3.0

func (this *Reader) GetRead() uint64

GetRead returns the number of bytes read so far

func (*Reader) Read added in v2.3.0

func (this *Reader) Read(block []byte) (int, error)

Read reads up to len(block) bytes and copies them into block. Returns the number of bytes read (0 <= n <= len(block)) and any error encountered. io.EOF is returned when the end of stream is reached.

func (*Reader) RemoveListener added in v2.3.0

func (this *Reader) RemoveListener(bl kanzi.Listener) bool

RemoveListener removes an event listener from this reader Returns true if the listener has been removed.

type Writer added in v2.3.0

type Writer struct {
	// contains filtered or unexported fields
}

Writer a Writer that writes compressed data to an OutputBitStream.

func NewWriter added in v2.3.0

func NewWriter(os io.WriteCloser, transform, entropy string, blockSize, jobs uint, checksum bool, fileSize int64, headerless bool) (*Writer, error)

NewWriter creates a new instance of Writer. The writer writes compressed data blocks to the provided os. Use 0 if the file size is not available Use headerless == false to create a bitstream without a header. The decompressor must know all the compression parameters to be able to decompress the bitstream. The headerless mode is only useful in very specific scenarios.

func NewWriterWithCtx added in v2.3.0

func NewWriterWithCtx(os io.WriteCloser, ctx map[string]any) (*Writer, error)

NewWriterWithCtx creates a new instance of Writer using a map of parameters and a writer. The writer writes compressed data blocks to the provided os using a default output bitstream.

func NewWriterWithCtx2 added in v2.3.0

func NewWriterWithCtx2(obs kanzi.OutputBitStream, ctx map[string]any) (*Writer, error)

NewWriterWithCtx2 creates a new instance of Writer using a map of parameters and a custom output bitstream. The writer writes compressed data blocks to the provided output bitstream.

func (*Writer) AddListener added in v2.3.0

func (this *Writer) AddListener(bl kanzi.Listener) bool

AddListener adds an event listener to this writer. Returns true if the listener has been added.

func (*Writer) Close added in v2.3.0

func (this *Writer) Close() error

Close writes the buffered data to the writer then writes a final empty block and releases resources. Close makes the bitstream unavailable for further writes. Idempotent.

func (*Writer) GetWritten added in v2.3.0

func (this *Writer) GetWritten() uint64

GetWritten returns the number of bytes written so far

func (*Writer) RemoveListener added in v2.3.0

func (this *Writer) RemoveListener(bl kanzi.Listener) bool

RemoveListener removes an event listener from this writer. Returns true if the listener has been removed.

func (*Writer) Write added in v2.3.0

func (this *Writer) Write(block []byte) (int, error)

Write writes len(block) bytes from block to the underlying data stream. Returns the number of bytes written from block (0 <= n <= len(block)) and any error encountered that caused the write to stop early.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL