cereal

package module
v0.0.0-...-b67bcea Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataType

type DataType int
const (
	Any DataType = iota
	Boolean
	Integer
	UnsignedInteger
	Float
	Byte
	Bytes
	String
	StringSlice
	KeyValueMap
)

func (DataType) String

func (d DataType) String() string

type HashWriter

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

func NewHashWriter

func NewHashWriter(w io.Writer) *HashWriter

NewHashWriter returns a new HashWriter which wraps the provided writer.

func (*HashWriter) CRC32

func (h *HashWriter) CRC32() uint32

CRC32 will return the CRC-32 hash of the written content.

func (*HashWriter) Count

func (h *HashWriter) Count() uint64

Count returns the number of bytes written.

func (*HashWriter) Write

func (h *HashWriter) Write(p []byte) (n int, err error)

Write writes the provided bytes to the wrapped writer, recalculates the checksum and counts the bytes.

func (*HashWriter) WriteByte

func (h *HashWriter) WriteByte(b byte) (err error)

type Reader

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

func NewReader

func NewReader(r io.ReadSeeker) *Reader

func NewReaderFromBuffer

func NewReaderFromBuffer(buf []byte) *Reader

func (*Reader) DecompressToFile

func (r *Reader) DecompressToFile(filePath string) error

DecompressToFile will read in the entire reader buffer and decompress it to the specified file.

func (*Reader) Read

func (r *Reader) Read(expectedType DataType) (interface{}, DataType, error)

Read will read the next value out of the buffer.

func (*Reader) ReadCompressedBlock

func (r *Reader) ReadCompressedBlock(out []byte) (err error)

ReadCompressedBlock will read the next block and decompress it into out.

func (*Reader) ReadGivenType

func (r *Reader) ReadGivenType(givenType DataType) (interface{}, DataType, error)

ReadGivenType will read the next value given the type.

func (*Reader) ReadRaw

func (r *Reader) ReadRaw(out []byte) (n int, err error)

ReadRaw reads data into out and returns the number of bytes read into out.

type Writer

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

func NewWriter

func NewWriter(f *os.File) *Writer

NewWriter will return a new writer.

func NewWriterFromBuffer

func NewWriterFromBuffer(buf *bytes.Buffer) *Writer

NewBufferFromBuffer will return a new writer from a specified byte buffer.

func (*Writer) Close

func (w *Writer) Close() error

Close will close the writer.

func (*Writer) Offset

func (w *Writer) Offset() uint64

Offset returns the current writer offset.

func (*Writer) SeekOffset

func (w *Writer) SeekOffset(offset uint64) error

func (*Writer) SetExcludeWriteType

func (w *Writer) SetExcludeWriteType(b bool)

SetExcludeWriteType will toggle whether data type enums are written to the buffer.

func (*Writer) Write

func (w *Writer) Write(data interface{}) (offset uint64, length int, err error)

func (*Writer) WriteRaw

func (w *Writer) WriteRaw(buf []byte) (offset uint64, err error)

WriteRaw will write the raw bytes into the writer.

func (*Writer) WriteRawByte

func (w *Writer) WriteRawByte(b byte) (offset uint64, err error)

WriteRawByte will write a single byte into the writer.

func (*Writer) WriteRawToLZ4Compress

func (w *Writer) WriteRawToLZ4Compress(buf []byte) (offset uint64, length int, err error)

WriteRawToCompress will write raw bytes to compress into LZ4, then to the writer.

Jump to

Keyboard shortcuts

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