decoder

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

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 Translate

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

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

func NewEscDecoder(lut id.TriceIDLookUp, m *sync.RWMutex, 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 NewFlexDecoder added in v0.21.0

func NewFlexDecoder(lut id.TriceIDLookUp, m *sync.RWMutex, in io.Reader, endian bool) Decoder

NewFlexDecoder 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 Flex added in v0.21.0

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

Flex is the Decoding instance for bare encoded trices.

func (*Flex) Read added in v0.21.0

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

Read is the provided read method for flex 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