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 ¶
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.
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.