lzma

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package lzma is a thin wrapper around the C lzma2 library.

The emphasis is on the word "thin". This package does not provide an idiomatic Go API; rather, it simply wraps C functions and types with analogous Go functions and types. A nice Go API should be built on top of this package.

The documentation for each type and function in this package generally just contains a reference to to the underlying C type or function in the /src/liblzma/api/ directory of the upstream C repository. Full documentation for the type and function can be found by looking at the excellent documentation on the C side.

Index

Constants

View Source
const (
	Ok               Return = 0
	StreamEnd               = 1
	NoCheck                 = 2
	UnsupportedCheck        = 3
	GetCheck                = 4
	MemoryError             = 5
	MemoryLimitError        = 6
	FormatError             = 7
	OptionsError            = 8
	DataError               = 9
	BufferError             = 10
	ProgrammingError        = 11
	SeekNeeded              = 12
)
View Source
const (
	Run         Action = 0
	SyncFlush          = 1
	FullFlush          = 2
	Finish             = 3
	FullBarrier        = 4
)

Variables

This section is empty.

Functions

func End

func End(stream *Stream)

End wraps lzma_end in base.h.

Types

type Action

type Action int

Action corresponds to the lzma_action type in base.h.

func (Action) String

func (a Action) String() string

type Return

type Return int

Return corresponds to the lzma_ret type in base.h.

func Code

func Code(stream *Stream, action Action) Return

Code wraps lzma_code in base.h.

func EasyEncoder

func EasyEncoder(stream *Stream, preset int) Return

EasyEncoder wraps lzma_easy_encoder in container.h.

func StreamDecoder

func StreamDecoder(stream *Stream) Return

StreamDecoder wraps lzma_stream_decoder in container.h.

func (Return) IsErr

func (r Return) IsErr() bool

IsErr returns true if the return code indicates an error condition.

func (Return) String

func (r Return) String() string

type Stream

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

Stream wraps lzma_stream in base.h and the input and output buffers that the lzma_stream type requires to exist.

The lzma_stream type operates on the two buffers but does not take ownership of them. This type thus contains handling for these buffers. This part of the package is the most Go-like because it needs to map from Go slices to C arrays, and ultimately hide the C implementation details.

func NewStream

func NewStream() *Stream

NewStream returns a new stream.

func (*Stream) AvailIn

func (stream *Stream) AvailIn() int

AvailIn returns the number of bytes that have been placed in the input buffer using the SetInput method that have yet to be processed by the stream.

func (*Stream) AvailOut

func (stream *Stream) AvailOut() int

AvailOut returns the number of bytes that the stream has written into the output buffer that have yet to be read using the Output method.

func (*Stream) Close

func (stream *Stream) Close()

Close closes the stream and releases C memory that has been allocated by the type.

func (*Stream) Output

func (stream *Stream) Output() []byte

Output returns all bytes that have been written to the output buffer by the stream, and resets the output buffer.

func (*Stream) SetInput

func (stream *Stream) SetInput(p []byte)

SetInput sets the input buffer of the stream to be the provided bytes. Note this overwrites any data that is already in the input buffer, so before calling SetInput it's best to verify that AvailIn returns 0.

func (*Stream) TotalIn

func (stream *Stream) TotalIn() int

TotalIn returns the total number of bytes that have been read from the input buffer.

func (*Stream) TotalOut

func (stream *Stream) TotalOut() int

TotalOut returns the total number of bytes that have been written to the input buffer

Jump to

Keyboard shortcuts

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