tlv

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package tlv implements encoding and decoding of TLV (type-length-value or tag-length-value) as defined in EMV Payment Code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder reads and decodes TLV payload from an input stream.

func NewDecoder

func NewDecoder(r io.RuneReader, tagName string, bufSize, tagLength, lenLength int, f TagLengthTranslator) *Decoder

NewDecoder returns a new decoder that reads from r.

func (*Decoder) Decode

func (d *Decoder) Decode(dst interface{}) error

Decode reads the next TLV value from its input and stores it in the value pointed to by dst.

type Encoder

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

Encoder writes EMV Payment Code payload to an output stream.

func NewEncoder

func NewEncoder(w io.Writer, tagName string, ignoreTags []string, f TagLengthTranslator) *Encoder

NewEncoder returns a new encoder that writes to w.

func (*Encoder) Encode

func (e *Encoder) Encode(src interface{}) error

Encode writes TLV payload of src to the stream.

type FieldMissingErr

type FieldMissingErr struct {
	Tag string
}

FieldMissingErr represents error of field not found for tag.

func (*FieldMissingErr) Error

func (e *FieldMissingErr) Error() string

type MalformedPayloadError

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

MalformedPayloadError indicates given payload is malformed.

func (*MalformedPayloadError) Error

func (e *MalformedPayloadError) Error() string

type Scanner

type Scanner interface {
	Scan([]rune) (err error)
}

Scanner is interface for parse various types

type TLV

type TLV struct {
	Tag    string
	Length string
	Value  string
}

TLV represents a chunk of TLV payload.

type TagLengthTranslator

type TagLengthTranslator interface {
	Translate(srcTagName, srcLength []rune) ([]rune, []rune)
}

TagLengthTranslator is a interface of Tag/Length value translator.

type TagLengthTranslatorFunc

type TagLengthTranslatorFunc func(srcTagName, srcLength []rune) ([]rune, []rune)

TagLengthTranslatorFunc type is an adapter to allow the use of ordinary functions as TagLengthTranslator.

func (TagLengthTranslatorFunc) Translate

func (f TagLengthTranslatorFunc) Translate(srcTagName, srcLength []rune) ([]rune, []rune)

Translate calls f(srcTagName, srcLength).

type Tokenizer

type Tokenizer interface {
	Tokenize() (string, error)
}

Tokenizer is the interface providing the Tokenize method.

Jump to

Keyboard shortcuts

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