decoder

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package decoder provides several decoders for differently encoded trice streams.

Package decoder provides several decoders for differently encoded trice streams.

Package decoder provides several decoders for differently encoded trice streams.

Package decoder provides several decoders for differently encoded trice streams.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Verbose gives mor information on output if set. The value is injected from main packages.
	Verbose bool

	// Encoding describes the way the byte stream is coded.
	Encoding string
)

Functions

func Translate

func Translate(sw *emitter.TriceLineComposer, list *id.List, rc io.ReadCloser) bool

Translate performs the trice log task. Bytes are read with rc, according decoder.Encoding are translated into strings returns false on program end signal or true on hard read error.

func UnmarshalTriceIDList

func UnmarshalTriceIDList(til []byte) (list []id.Item, err error)

UnmarshalTriceIDList extracts the trice ID list byte slice to an items slice. til is a result of a read til.json file or is a converted test string. til can change during runtime, when an "trice update" occurs. Just in case til is not consistent the err value is not nil.

Types

type Bare

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

Bare is the Decoder instance for bare encoded trices.

func NewBare

func NewBare(l []id.Item, in io.Reader) (p *Bare)

NewBare provides an BareDecoder instance. l is the trice id list in slice of struct format. in is the usable reader for the input bytes.

func (*Bare) StringsRead

func (p *Bare) StringsRead(ss []string) (m int, err error)

StringsRead is the provided read method for bare decoding. It uses inner reader and internal id look-up table to fill ss. ss is a slice of strings with a len for the max expected strings. m is the count of decoded strings inside ss.

type BareReaderFromWrap

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

BareReaderFromWrap provides a Read method for bare data from wrapped data

func NewBareReaderFromWrap

func NewBareReaderFromWrap(in io.Reader) *BareReaderFromWrap

NewBareReaderFromWrap returns a pointer to a BareReaderFromWrap instance which is satisfying the io.Reader interface and using `in` as internal reader. It assumes wrap coded trices in the input byte stream. It uses the wrapper bytes for syncing and removes them silently.

func (*BareReaderFromWrap) Read

func (p *BareReaderFromWrap) Read(buf []byte) (int, error)

Read is the provided method for interface satisfying.

type Decoder

type Decoder interface {
	StringsReader
}

Decoder is the interface (method set) a decoder needs to provide

type Esc

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

Esc is the Decoder instance for esc encoded trices.

func NewEsc

func NewEsc(l []id.Item, in io.Reader) (p *Esc)

NewEsc provides an EscDecoder instance. l is the trice id list in slice of struct format. in is the usable reader for the input bytes.

func (*Esc) StringsRead

func (p *Esc) StringsRead(ss []string) (m int, err error)

StringsRead is the provided read method for esc decoding. It uses inner reader and internal id look-up table to fill ss. ss is a slice of strings with a len for the max expected strings. m is the count of decoded strings inside ss.

type IDLookUp

type IDLookUp map[int]idFmt

IDLookUp is the ID to format info translation map

func MakeLut

func MakeLut(list []id.Item) (lut IDLookUp)

MakeLut returns a trice ID lookup map.

type StringsReader

type StringsReader interface {
	StringsRead(p []string) (n int, err error)
}

StringsReader as Decoder method uses an underlying (byte) Reader for reading and returns max len(p) strings inside p. n is the received amount of strings. err is the underlying Reader error or an internal error.

Jump to

Keyboard shortcuts

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