checksum

package
v1.1.0-beta.0...-d02d48a Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader implements an io.ReadAt, reading from the input source after verifying the checksum.

func NewReader

func NewReader(r io.ReaderAt) *Reader

NewReader returns a new Reader which can read from the input source after verifying the checksum.

func (*Reader) ReadAt

func (r *Reader) ReadAt(p []byte, off int64) (nn int, err error)

ReadAt implements the io.ReadAt interface.

type Writer

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

Writer implements an io.WriteCloser, it calculates and stores a CRC-32 checksum for the payload before writing to the underlying object.

For example, a layout of the checksum block which payload is 2100 bytes is as follow:

| -- 4B -- | -- 1020B -- || -- 4B -- | -- 1020B -- || -- 4B -- | -- 60B -- | | -- checksum -- | -- payload -- || -- checksum -- | -- payload -- || -- checksum -- | -- payload -- |

func NewWriter

func NewWriter(w io.WriteCloser) *Writer

NewWriter returns a new Writer which calculates and stores a CRC-32 checksum for the payload before writing to the underlying object.

func (*Writer) AvailableSize

func (w *Writer) AvailableSize() int

AvailableSize returns how many bytes are unused in the buffer.

func (*Writer) Buffered

func (w *Writer) Buffered() int

Buffered returns the number of bytes that have been written into the current buffer.

func (*Writer) Close

func (w *Writer) Close() (err error)

Close implements the io.Closer interface.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush writes all the buffered data to the underlying object.

func (*Writer) GetCache

func (w *Writer) GetCache() []byte

GetCache returns the byte slice that holds the data not flushed to disk.

func (*Writer) GetCacheDataOffset

func (w *Writer) GetCacheDataOffset() int64

GetCacheDataOffset return the user data offset in cache.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

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