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 ¶
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 )
const ( Run Action = 0 SyncFlush = 1 FullFlush = 2 Finish = 3 FullBarrier = 4 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Return ¶
type Return int
Return corresponds to the lzma_ret type in base.h.
func EasyEncoder ¶
EasyEncoder wraps lzma_easy_encoder in container.h.
func StreamDecoder ¶
StreamDecoder wraps lzma_stream_decoder in container.h.
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 (*Stream) AvailIn ¶
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 ¶
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 ¶
Output returns all bytes that have been written to the output buffer by the stream, and resets the output buffer.
func (*Stream) SetInput ¶
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.