readerwriter

package
v2.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChecksumSize is 128bits for cityhash102 checksum
	ChecksumSize = 16
	// CompressHeaderSize magic + compressed_size + uncompressed_size
	CompressHeaderSize = 1 + 4 + 4

	// HeaderSize for compress header
	HeaderSize = ChecksumSize + CompressHeaderSize
	// BlockMaxSize 1MB
	BlockMaxSize = 1024 * 1024 * 128
)

Variables

This section is empty.

Functions

func NewCompressReader

func NewCompressReader(r io.Reader) io.Reader

NewCompressReader wrap the io.Reader

func NewCompressWriter

func NewCompressWriter(w io.Writer, method byte) io.Writer

NewCompressWriter wrap the io.Writer

Types

type CompressMethod

type CompressMethod byte

Method is compression codec.

const (
	CompressNone     CompressMethod = 0x00
	CompressChecksum CompressMethod = 0x02
	CompressLZ4      CompressMethod = 0x82
	CompressZSTD     CompressMethod = 0x90
)

Possible compression methods.

type CorruptedDataErr

type CorruptedDataErr struct {
	Actual    city.U128
	Reference city.U128
	RawSize   int
	DataSize  int
}

CorruptedDataErr means that provided hash mismatch with calculated.

func (*CorruptedDataErr) Error

func (c *CorruptedDataErr) Error() string

type Reader

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

Reader is a helper to read data from reader

func NewReader

func NewReader(input io.Reader) *Reader

NewReader get new Reader

func (*Reader) ByteString

func (r *Reader) ByteString() ([]byte, error)

ByteString read string value as []byte

func (*Reader) FixedString

func (r *Reader) FixedString(strlen int) ([]byte, error)

FixedString read FixedString value

func (*Reader) Int32

func (r *Reader) Int32() (int32, error)

Int32 read Int32 value

func (*Reader) Read

func (r *Reader) Read(buf []byte) (int, error)

Read implement Read

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

ReadByte read a single byte

func (*Reader) SetCompress

func (r *Reader) SetCompress(c bool)

SetCompress set compress statusp

func (*Reader) String

func (r *Reader) String() (string, error)

String read String value

func (*Reader) Uint32

func (r *Reader) Uint32() (uint32, error)

Uint32 read Uint32 value

func (*Reader) Uint64

func (r *Reader) Uint64() (uint64, error)

Uint64 read Uint64 value

func (*Reader) Uvarint

func (r *Reader) Uvarint() (uint64, error)

Uvarint read variable uint64 value

type Writer

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

Writer is a helper to write data into bytes.Buffer

func NewWriter

func NewWriter() *Writer

NewWriter get new writer

func (*Writer) ByteString

func (w *Writer) ByteString(v []byte)

ByteString write []byte

func (*Writer) Int32

func (w *Writer) Int32(v int32)

Int32 write Int32 value

func (*Writer) Int64

func (w *Writer) Int64(v int64)

Int64 write Int64 value

func (*Writer) Output

func (w *Writer) Output() *bytes.Buffer

Output get raw *bytes.Buffer

func (*Writer) Reset

func (w *Writer) Reset()

Reset reset all data

func (*Writer) String

func (w *Writer) String(v string)

String write string

func (*Writer) Uint32

func (w *Writer) Uint32(v uint32)

Uint32 write Uint32 value

func (*Writer) Uint64

func (w *Writer) Uint64(v uint64)

Uint64 write Uint64 value

func (*Writer) Uint8

func (w *Writer) Uint8(v uint8)

Uint8 write Uint8 value

func (*Writer) Uvarint

func (w *Writer) Uvarint(v uint64)

Uvarint write a variable uint64 value into writer

func (*Writer) Write

func (w *Writer) Write(b []byte)

Write write raw []byte data

func (*Writer) WriteTo

func (w *Writer) WriteTo(wt io.Writer) (int64, error)

WriteTo implement WriteTo

Jump to

Keyboard shortcuts

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