digest

package
v0.0.0-...-ad801e6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package digest is a generated GoMock package.

Index

Constants

View Source
const (
	// DigestLenBytes is the length of generated digests in bytes.
	DigestLenBytes = 4
)

Variables

This section is empty.

Functions

func Checksum

func Checksum(buf []byte) uint32

Checksum returns the checksum for a buffer.

func NewDigest

func NewDigest() stackadler32.Digest

NewDigest creates a new digest. The default 32-bit hashing algorithm is adler32.

func Validate

func Validate(b []byte) ([]byte, error)

Validate validates the data in the buffer against its checksum. The checksum is at the end of the buffer occupying `numChecksumBytes` bytes.

Types

type Buffer

type Buffer []byte

Buffer is a byte slice that facilitates digest reading and writing.

func NewBuffer

func NewBuffer() Buffer

NewBuffer creates a new digest buffer.

func ToBuffer

func ToBuffer(buf []byte) Buffer

ToBuffer converts a byte slice to a digest buffer.

func (Buffer) ReadDigest

func (b Buffer) ReadDigest() uint32

ReadDigest reads the digest from the buffer.

func (Buffer) ReadDigestFromFile

func (b Buffer) ReadDigestFromFile(fd *os.File) (uint32, error)

ReadDigestFromFile reads the digest from the file.

func (Buffer) WriteDigest

func (b Buffer) WriteDigest(digest uint32)

WriteDigest writes a digest to the buffer.

func (Buffer) WriteDigestToFile

func (b Buffer) WriteDigestToFile(fd *os.File, digest uint32) error

WriteDigestToFile writes a digest to the file.

type FdWithDigestWriter

type FdWithDigestWriter interface {
	io.Writer

	Flush() error
	// contains filtered or unexported methods
}

FdWithDigestWriter provides a buffered writer for writing to the underlying file.

type FileWithDigestWriter

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

FileWithDigestWriter writes data to a file and computes the data checksum in a streaming fashion.

func NewFdWithDigestWriter

func NewFdWithDigestWriter(bufferSize int) *FileWithDigestWriter

NewFdWithDigestWriter creates a new FdWithDigestWriter.

func (*FileWithDigestWriter) Close

func (w *FileWithDigestWriter) Close() error

Close writes the final checksum to file, flushes what's remaining in the buffered writer, and closes the underlying file.

func (*FileWithDigestWriter) Flush

func (w *FileWithDigestWriter) Flush() error

Flush flushes what's remaining in the buffered writes.

func (*FileWithDigestWriter) Reset

func (w *FileWithDigestWriter) Reset(fd *os.File)

Reset resets the writer.

func (*FileWithDigestWriter) Write

func (w *FileWithDigestWriter) Write(b []byte) (int, error)

Write bytes to the underlying file.

type MockFdWithDigestWriter

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

MockFdWithDigestWriter is a mock of FdWithDigestWriter interface

func NewMockFdWithDigestWriter

func NewMockFdWithDigestWriter(ctrl *gomock.Controller) *MockFdWithDigestWriter

NewMockFdWithDigestWriter creates a new mock instance

func (*MockFdWithDigestWriter) Close

func (m *MockFdWithDigestWriter) Close() error

Close mocks base method

func (*MockFdWithDigestWriter) Digest

func (m *MockFdWithDigestWriter) Digest() hash.Hash32

Digest mocks base method

func (*MockFdWithDigestWriter) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockFdWithDigestWriter) Fd

func (m *MockFdWithDigestWriter) Fd() *os.File

Fd mocks base method

func (*MockFdWithDigestWriter) Flush

func (m *MockFdWithDigestWriter) Flush() error

Flush mocks base method

func (*MockFdWithDigestWriter) Reset

func (m *MockFdWithDigestWriter) Reset(arg0 *os.File)

Reset mocks base method

func (*MockFdWithDigestWriter) Write

func (m *MockFdWithDigestWriter) Write(arg0 []byte) (int, error)

Write mocks base method

type MockFdWithDigestWriterMockRecorder

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

MockFdWithDigestWriterMockRecorder is the mock recorder for MockFdWithDigestWriter

func (*MockFdWithDigestWriterMockRecorder) Close

Close indicates an expected call of Close

func (*MockFdWithDigestWriterMockRecorder) Digest

Digest indicates an expected call of Digest

func (*MockFdWithDigestWriterMockRecorder) Fd

Fd indicates an expected call of Fd

func (*MockFdWithDigestWriterMockRecorder) Flush

Flush indicates an expected call of Flush

func (*MockFdWithDigestWriterMockRecorder) Reset

func (mr *MockFdWithDigestWriterMockRecorder) Reset(arg0 interface{}) *gomock.Call

Reset indicates an expected call of Reset

func (*MockFdWithDigestWriterMockRecorder) Write

func (mr *MockFdWithDigestWriterMockRecorder) Write(arg0 interface{}) *gomock.Call

Write indicates an expected call of Write

Jump to

Keyboard shortcuts

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