encoding

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2017 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentVersion uint32 = 1

CurrentVersion the current format version used for encoding and decoding

View Source
var ErrBookNoteFound = errors.New("Note how unknown book")

ErrBookNoteFound indicates that the parser encountered a Note record that referenced a Book the parse has not parsed yet.

View Source
var ErrHeaderNotParsed = errors.New("Header have not been parsed yet")

ErrHeaderNotParsed indicates that the Header was not read before attempting to read a record

View Source
var ErrHeaderNotWritten = errors.New("Header have not been written yet")

ErrHeaderNotWritten indicates that the Header was not written before attempting to write a record.

View Source
var ErrInvalidOrCorruptedBinaryFormat = errors.New("Invalid or corrupted binary")

ErrInvalidOrCorruptedBinaryFormat indicates that parser encountered an problem with the QNOT stream and is unable to continue.

View Source
var ErrInvalidRecordType = errors.New("Encountered an invalid record type")

ErrInvalidRecordType indicates a invalid record was encountered. See RecordType for a list of valid records types.

View Source
var ErrInvalidString = errors.New("Encountered an invalid record string")

ErrInvalidString indicates the parser encountered a string that does not meets the requirements of Entity's field (such as a string was to long)

View Source
var ErrTagNoteFound = errors.New("Note how unknown tag")

ErrTagNoteFound indicates that the parser encountered a Note record that referenced a Tag the parse has not parsed yet.

View Source
var HeaderLen = 16

HeaderLen length of the header block

View Source
var MagicStr = "QNOT"

MagicStr binary magic string

Functions

This section is empty.

Types

type BinaryDecoder

type BinaryDecoder struct {
	Header *Header
	Err    error
	// contains filtered or unexported fields
}

BinaryDecoder Decodes a QNOT file into a list of Notes

func NewBinaryDecoder

func NewBinaryDecoder(r io.Reader) *BinaryDecoder

NewBinaryDecoder returns a new BinaryDecoder

func (*BinaryDecoder) ParseHeader

func (d *BinaryDecoder) ParseHeader() error

ParseHeader parses the Header block This must be called before calling ParseNotes() It is an error not to

func (*BinaryDecoder) ParseNotes

func (d *BinaryDecoder) ParseNotes() (<-chan *note.Note, error)

ParseNotes starts the parser and returns a Note channel Must call ParseHeader() first or an error is returned

type BinaryEncoder

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

BinaryEncoder encodes a Note into the QNOT format

func NewBinaryEncoder

func NewBinaryEncoder(w io.Writer) *BinaryEncoder

NewBinaryEncoder returns a new BinaryEncoder

func (*BinaryEncoder) WriteHeader

func (b *BinaryEncoder) WriteHeader() (uint64, error)

WriteHeader writes the Header block to w. This must be called before any Note can be encoded Calling WriteHeader() more than once has no effect.

func (*BinaryEncoder) WriteNote

func (b *BinaryEncoder) WriteNote(n *note.Note) (uint64, error)

WriteNote encodes a Note, it's Book, and Tags then writes them to w. Books and Tags are only encoded and written to w once. Meaning, if they are encountered again in a different note, they will not be encoded again.

type Header struct {
	Version int32
	Created time.Time
}

Header QNOT file header block

type RecordType

type RecordType byte

RecordType byte indicating the type of record

var (
	Book RecordType = 0
	Tag  RecordType = 1
	Note RecordType = 2
)

List of record types

Jump to

Keyboard shortcuts

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