Documentation ¶
Overview ¶
Package delimited implements a simple reader and writer for streams of length-delimited byte records. Each record is written as a varint-encoded length in bytes, followed immediately by the record itself. A stream consists of a sequence of such records packed consecutively without additional padding. No checksums or compression are being used.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataSource ¶
type DataSource interface { // Next will return the next record in the sequence // Note: // - io.EOF is returned when no further records are available // - the slice returned by Next() is only required to be valid until a subsequent call to Next() Next() ([]byte, error) }
DataSource represents a sequence of records.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads length-delimited records from a byte data source.
func (*Reader) Next ¶
Next returns the next length-delimited record from the input Note:
- returns io.EOF if there are no more records available
- returns io.ErrUnexpectedEOF if a short record is found, with a length of n but fewer than n bytes of data
- since there is no resynchronization mechanism, it is generally not possible to recover from a short record in this format
The slice returned is valid only until a subsequent call to Next.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer outputs delimited records to an io.Writer.