io

package
v0.0.0-...-3c2e606 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TFRecord

type TFRecord struct {
	Data []byte
	// contains filtered or unexported fields
}

A TFRecord is an in-memory representation of a completely read TFRecord. Its Data contains the decoded buffer contents. The record internally has a stored CRC, which is as originally read from the file or given at construction time. It may or may not match the Data.

func NewTFRecord

func NewTFRecord(data []byte) TFRecord

NewTFRecord creates a TFRecord from an in-memory buffer, computing its checksum.

func NewTFRecordChecksum

func NewTFRecordChecksum(data []byte, maskedCRC uint32) TFRecord

NewTFRecordChecksum creates a TFRecord from an in-memory buffer and pre-computed checksum. The checksum is not validated, so calling Checksum() on the resulting record may fail.

func ReadRecord

func ReadRecord(statePtr **TFRecordState, r io.Reader) (*TFRecord, error)

ReadRecord attempts to read a TFRecord, behaving nicely in the face of truncations. If the record is truncated, the first return value is nil and the second is io.EOF, and the state buffer will be updated to contain the prefix of the raw record that was read. The same state buffer should be passed to a subsequent call to ReadRecord that it may continue where it left off. The state buffer must not be nil, but may point to nil, and indeed must point to nil on the first invocation for each record.

The record's length field is always validated against its checksum, but the full data is only validated if you call Checksum() on the result.

func (*TFRecord) ByteSize

func (rec *TFRecord) ByteSize() int

ByteSize returns the size of the serialized form of the record: i.e., the number of bytes that would be written by Write. This is the length of its Data plus the overhead of the TFRecord format.

func (*TFRecord) Checksum

func (rec *TFRecord) Checksum() error

Checksum validates the integrity of the record by computing its CRC-32 and checking it against the expected value. It returns an error if the CRCs do not match.

func (*TFRecord) Write

func (rec *TFRecord) Write(w io.Writer) error

Write writes the serialized TFRecord form. The stored data checksum is used, so if the stored checksum is inaccurate then the written checksum will be, too. Write only returns an error if the underlying writer does.

type TFRecordState

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

TFRecordState is the reentrance structure for ReadRecord.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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