decoder

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2021 License: MIT Imports: 15 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.

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

	// TestTableMode is a special option for easy decoder test table generation.
	TestTableMode bool

	// UnsignedHex if true, forces hex and in values printed as unsigned values.
	UnsignedHex bool
)

Functions

func NewBareReaderFromWrap

func NewBareReaderFromWrap(in io.Reader) io.Reader

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 Translate

func Translate(sw *emitter.TriceLineComposer, lut id.TriceIDLookUp, rc io.ReadCloser) bool

Translate performs the trice log task. Bytes are read with rc. Then according decoder.Encoding they are translated into strings. Each read returns the amount of bytes for one trice. rc is called on every Translate returns true on io.EOF or false on hard read error or sigterm.

Types

type Bare

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

Bare is the Decoding instance for bare encoded trice's.

func (*Bare) Read added in v0.18.4

func (p *Bare) Read(b []byte) (n int, err error)

Read is the provided read method for bare decoding of next string as byte slice. It uses inner reader p.in and internal id look-up table to fill b with a string. b is a slice of bytes with a len for the max expected string size. n is the count of read bytes inside b. Read returns one trice string (optionally starting wth a channel specifier). A line can contain several trice strings.

type BareReaderFromWrap

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

BareReaderFromWrap provides a Read method for bare data from wrapped data

func (*BareReaderFromWrap) Read

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

Read is the provided method for interface satisfying.

type Decoder

type Decoder interface {
	io.Reader
	// contains filtered or unexported methods
}

Decoder is providing a byte reader returning decoded trice's. setInput allows switching the input stream to a different source.

func NewBareDecoder added in v0.18.4

func NewBareDecoder(lut id.TriceIDLookUp, in io.Reader, endian bool) Decoder

NewBareDecoder 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 NewEscDecoder added in v0.18.4

func NewEscDecoder(lut id.TriceIDLookUp, in io.Reader, endian bool) Decoder

NewEscDecoder 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 NewPack2Decoder added in v0.18.4

func NewPack2Decoder(lut id.TriceIDLookUp, in io.Reader, endian bool) Decoder

NewPack2Decoder provides an decoder instance. l is the trice id list in slice of struct format. in is the usable reader for the input bytes. littleEndian is false on normal network order.

func NewPackDecoder added in v0.18.4

func NewPackDecoder(lut id.TriceIDLookUp, in io.Reader, endian bool) Decoder

NewPackDecoder provides an decoder instance. l is the trice id list in slice of struct format. in is the usable reader for the input bytes. littleEndian is false on normal network order.

type Esc

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

Esc is the Decoding instance for esc encoded trices.

func (*Esc) Read added in v0.18.4

func (p *Esc) Read(b []byte) (n int, err error)

Read is the provided read method for esc decoding of next string as byte slice. It uses inner reader p.in and internal id look-up table to fill b with a string. b is a slice of bytes with a len for the max expected string size. n is the count of read bytes inside b. Read returns one trice string or nothing.

type Pack added in v0.18.4

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

Pack is the Decoding instance for bare encoded trices.

func (*Pack) Read added in v0.18.4

func (p *Pack) Read(b []byte) (n int, err error)

Read is the provided read method for pack decoding of next string as byte slice. It uses inner reader p.in and internal id look-up table to fill b with a string. b is a slice of bytes with a len for the max expected string size. n is the count of read bytes inside b. Read returns one trice string (optionally starting wth a channel specifier). A line can contain several trice strings.

type Pack2 added in v0.18.4

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

Pack2 is the Decoding instance for bare encoded trices.

func (*Pack2) Read added in v0.18.4

func (p *Pack2) Read(b []byte) (n int, err error)

Read is the provided read method for pack decoding of next string as byte slice. It uses inner reader p.in and internal id look-up table to fill b with a string. b is a slice of bytes with a len for the max expected string size. n is the count of read bytes inside b. Read returns one trice string (optionally starting wth a channel specifier). A line can contain several trice strings.

Jump to

Keyboard shortcuts

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