serialdata

package module
v0.0.0-...-69be54f Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: BSD-3-Clause Imports: 4 Imported by: 3

README

go-serialdata

Basic implementation of a writer of arbitrary serial data.

Documentation

Overview

The serialdata package implements readers and writers for writing and accessing data which is structured into lists of records in files or other Reader/Writer type data structures.

Index

Constants

This section is empty.

Variables

View Source
var ENOBUFS error = errors.New("No buffer space available")

An error returned if the buffer isn't large enough to hold the next record.

Functions

This section is empty.

Types

type SerialDataReader

type SerialDataReader struct {
	io.ReadSeeker
	// contains filtered or unexported fields
}

A reader for a serial structure of consecutive data.

func NewSerialDataReader

func NewSerialDataReader(r io.Reader) *SerialDataReader

Create a new record reader around "r".

func (*SerialDataReader) Read

func (s *SerialDataReader) Read(data []byte) (int, error)

Read the next record from the wrapped reader. If the reader supports seek and the read fails, the position will be rolled back.

func (*SerialDataReader) ReadMessage

func (s *SerialDataReader) ReadMessage(pb proto.Message) error

Read the next record and interpret it as a protocol buffer message.

func (*SerialDataReader) ReadRecord

func (s *SerialDataReader) ReadRecord() ([]byte, error)

Read exactly the next records worth of bytes from the reader and return its contents.

func (*SerialDataReader) Seek

func (s *SerialDataReader) Seek(offset int64, whence int) (int64, error)

Support seeks if the underlying object has got seek support. Seeks must always occur to the beginning of a record. This is mostly useful for reading from indexes.

type SerialDataWriter

type SerialDataWriter struct {
	io.WriteSeeker
	// contains filtered or unexported fields
}

A writer for a serial structure of consecutive data.

func NewSerialDataWriter

func NewSerialDataWriter(w io.Writer) *SerialDataWriter

Create a new record writer around "w".

func (*SerialDataWriter) Seek

func (s *SerialDataWriter) Seek(offset int64, whence int) (int64, error)

Support seeks if the underlying object has got seek support. This is mostly used to report the current position rather than do actual seeks.

func (*SerialDataWriter) Write

func (s *SerialDataWriter) Write(data []byte) (int, error)

Write the data designated as "data" to the wrapped writer. It will be written as a separate new record.

func (*SerialDataWriter) WriteMessage

func (s *SerialDataWriter) WriteMessage(pb proto.Message) error

Write the designated protobuf record to the underlying writer.

Jump to

Keyboard shortcuts

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