prefix

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASCII = Prefixers{
	Fixed: &asciiFixedPrefixer{},
	L:     &asciiVarPrefixer{1},
	LL:    &asciiVarPrefixer{2},
	LLL:   &asciiVarPrefixer{3},
	LLLL:  &asciiVarPrefixer{4},
}
View Source
var BCD = Prefixers{
	Fixed: &bcdFixedPrefixer{},
	L:     &bcdVarPrefixer{1},
	LL:    &bcdVarPrefixer{2},
	LLL:   &bcdVarPrefixer{3},
	LLLL:  &bcdVarPrefixer{4},
}
View Source
var BerTLV = &berTLVPrefixer{}

BerTLV encodes and decodes the length of BER-TLV fields based on the following rules:

Short Form: When the most-significant bit is off, the length field consists of only one byte in which the right-most 7 bits contain the number of bytes in the Value field, as an unsigned binary integer. This form of the Length field supports data lengths of 127 bytes. For example, a Length value of 126 can be encoded as binary 01111110 (hexadecimal equivalent of 7E).

Long Form: When the most-significant bit is on, the Length field consists of an initial byte and one or more subsequent bytes. The right-most 7 bits of the initial byte contain the number of subsequent bytes in the Length field, as an unsigned binary integer. All bits of the subsequent bytes contain an unsigned big-endian binary integer equal to the number of bytes in the Value field. For example, a Length value of 254 can be encoded as binary 10000001 11111110 (hexadecimal equivalent of 81FE).

View Source
var Binary = Prefixers{
	Fixed: &binaryFixedPrefixer{},
	L:     &binaryVarPrefixer{1},
	LL:    &binaryVarPrefixer{2},
	LLL:   &binaryVarPrefixer{3},
	LLLL:  &binaryVarPrefixer{4},
}
View Source
var EBCDIC = Prefixers{
	Fixed: &ebcdicFixedPrefixer{},
	L:     &ebcdicVarPrefixer{1},
	LL:    &ebcdicVarPrefixer{2},
	LLL:   &ebcdicVarPrefixer{3},
	LLLL:  &ebcdicVarPrefixer{4},
}
View Source
var EBCDIC1047 = Prefixers{
	Fixed: &ebcdic1047FixedPrefixer{},
	L:     &ebcdic1047Prefixer{1},
	LL:    &ebcdic1047Prefixer{2},
	LLL:   &ebcdic1047Prefixer{3},
	LLLL:  &ebcdic1047Prefixer{4},
}
View Source
var Hex = Prefixers{
	Fixed: &hexFixedPrefixer{},
	L:     &hexVarPrefixer{1},
	LL:    &hexVarPrefixer{2},
	LLL:   &hexVarPrefixer{3},
	LLLL:  &hexVarPrefixer{4},
}

Functions

This section is empty.

Types

type Prefixer

type Prefixer interface {
	// Returns field length encoded into []byte
	EncodeLength(maxLen, length int) ([]byte, error)

	// Returns the size of the field (number of characters, HEX-digits, bytes)
	// as well as the number of bytes read to decode the length
	DecodeLength(maxLen int, data []byte) (length int, read int, err error)

	// Returns human readable information about length prefixer. Returned value
	// is used to create prefixer when we build spec from a JSON spec.
	// Returned value should be in the following format:
	//  PrefixerName.Length
	// Examples:
	//  ASCII.LL
	//  Hex.Fixed
	Inspect() string
}

type PrefixerBuilder

type PrefixerBuilder func(int) Prefixer

type Prefixers

type Prefixers struct {
	Fixed Prefixer
	L     Prefixer
	LL    Prefixer
	LLL   Prefixer
	LLLL  Prefixer
}

Jump to

Keyboard shortcuts

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