Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeAny(decoder *Decoder, tag Tag) (value any, n int, err error)
- func DecodeAnyInto(decoder *Decoder, destination any, tag Tag) (n int, err error)
- func EncodeAny(encoder *Encoder, value any, tag Tag) (n int, err error)
- func IntBytes(value uint64) int
- func Skim(decoder *Decoder, tag Tag) (n int, err error)
- func Uint64ToIntSafe(input uint64) (int, error)
- type Decodable
- type Decoder
- func (this *Decoder) ReadFloat16() (value float32, n int, err error)
- func (this *Decoder) ReadFloat32() (value float32, n int, err error)
- func (this *Decoder) ReadFloat64() (value float64, n int, err error)
- func (this *Decoder) ReadFull(buffer []byte) (n int, err error)
- func (this *Decoder) ReadInt8() (value int8, n int, err error)
- func (this *Decoder) ReadInt16() (value int16, n int, err error)
- func (this *Decoder) ReadInt32() (value int32, n int, err error)
- func (this *Decoder) ReadInt64() (value int64, n int, err error)
- func (this *Decoder) ReadIntN(bytes int) (value int64, n int, err error)
- func (this *Decoder) ReadTag() (value Tag, n int, err error)
- func (this *Decoder) ReadUint8() (value uint8, n int, err error)
- func (this *Decoder) ReadUint16() (value uint16, n int, err error)
- func (this *Decoder) ReadUint32() (value uint32, n int, err error)
- func (this *Decoder) ReadUint64() (value uint64, n int, err error)
- func (this *Decoder) ReadUintN(bytes int) (value uint64, n int, err error)
- type Encodable
- type Encoder
- func (this *Encoder) WriteFloat16(value float32) (n int, err error)
- func (this *Encoder) WriteFloat32(value float32) (n int, err error)
- func (this *Encoder) WriteFloat64(value float64) (n int, err error)
- func (this *Encoder) WriteInt8(value int8) (n int, err error)
- func (this *Encoder) WriteInt16(value int16) (n int, err error)
- func (this *Encoder) WriteInt32(value int32) (n int, err error)
- func (this *Encoder) WriteInt64(value int64) (n int, err error)
- func (this *Encoder) WriteIntN(value int64, bytes int) (n int, err error)
- func (this *Encoder) WriteTag(value Tag) (n int, err error)
- func (this *Encoder) WriteUint8(value uint8) (n int, err error)
- func (this *Encoder) WriteUint16(value uint16) (n int, err error)
- func (this *Encoder) WriteUint32(value uint32) (n int, err error)
- func (this *Encoder) WriteUint64(value uint64) (n int, err error)
- func (this *Encoder) WriteUintN(value uint64, bytes int) (n int, err error)
- type Error
- type Tag
Constants ¶
const MaxInt int = int(^uint(0) >> 1)
MaxInt is the maximum value an int can hold. This varies depending on the system.
Variables ¶
var MaxStructureLength = 1024 * 1024
MaxStructureLength determines how long a TAPE data structure can be. This applies to:
- OTA
- SBA/LBA
- KTV
By default it is set at 2^20 (about a million). You shouldn't need to change this. If you do, it should only be set once at the start of the program.
Functions ¶
func DecodeAny ¶
DecodeAny is like DecodeAnyInto, but it automatically creates the destination from the tag and data. The head of the decoder must be at the start of the payload.
func DecodeAnyInto ¶
DecodeAnyInto decodes data and places it into destination, which must be a pointer to a supported type. See EncodeAny for a list of supported types. The head of the decoder must be at the start of the payload.
func EncodeAny ¶
EncodeAny encodes an "any" value. Returns an error if the underlying type is unsupported. Supported types are:
- int
- int<N>
- uint
- uint<N>
- string
- []<supported type>
- map[uint16]<supported type>
func Skim ¶
Skim uses up data from a decoder to "skim" over one value (and all else contained within it) without actually putting the data anywhere.
func Uint64ToIntSafe ¶
Uint64ToIntSafe casts the input to an int if it can be done without overflow, or returns an error otherwise.
Types ¶
type Decodable ¶
type Decodable interface {
// Decode reads data from decoder, replacing the data of the object. It
// returns the amount of bytes written, and an error if the write
// stopped early.
Decode(decoder *Decoder) (n int, err error)
}
Decodable is any type that can decode itself from a decoder.
type Decoder ¶
Decoder decodes data from an io.Reader.
func NewDecoder ¶
NewDecoder creates a new decoder that reads from reader.
func (*Decoder) ReadFloat16 ¶
ReadFloat16 decodes a 16-bit floating point value from the input reader.
func (*Decoder) ReadFloat32 ¶
ReadFloat32 decldes a 32-bit floating point value from the input reader.
func (*Decoder) ReadFloat64 ¶
ReadFloat64 decldes a 64-bit floating point value from the input reader.
func (*Decoder) ReadFull ¶
ReadFull calls io.ReadFull on the reader.
func (*Decoder) ReadUint16 ¶
ReadUint16 decodes an 16-bit unsigned integer from the input reader.
func (*Decoder) ReadUint32 ¶
ReadUint32 decodes an 32-bit unsigned integer from the input reader.
func (*Decoder) ReadUint64 ¶
ReadUint64 decodes an 64-bit unsigned integer from the input reader.
type Encodable ¶
type Encodable interface {
// Encode sends data to encoder. It returns the amount of bytes written,
// and an error if the write stopped early.
Encode(encoder *Encoder) (n int, err error)
}
Encodable is any type that can write itself to an encoder.
type Encoder ¶
Encoder encodes data to an io.Writer.
func NewEncoder ¶
NewEncoder creates a new encoder that writes to writer.
func (*Encoder) WriteFloat16 ¶
WriteFloat16 encodes a 16-bit floating point value to the output writer.
func (*Encoder) WriteFloat32 ¶
WriteFloat32 encodes a 32-bit floating point value to the output writer.
func (*Encoder) WriteFloat64 ¶
WriteFloat64 encodes a 64-bit floating point value to the output writer.
func (*Encoder) WriteInt16 ¶
WriteInt16 encodes an 16-bit signed integer to the output writer.
func (*Encoder) WriteInt32 ¶
WriteInt32 encodes an 32-bit signed integer to the output writer.
func (*Encoder) WriteInt64 ¶
WriteInt64 encodes an 64-bit signed integer to the output writer.
func (*Encoder) WriteUint8 ¶
WriteUint8 encodes an 8-bit unsigned integer to the output writer.
func (*Encoder) WriteUint16 ¶
WriteUint16 encodes an 16-bit unsigned integer to the output writer.
func (*Encoder) WriteUint32 ¶
WriteUint32 encodes an 32-bit unsigned integer to the output writer.
func (*Encoder) WriteUint64 ¶
WriteUint64 encodes an 64-bit unsigned integer to the output writer.
type Tag ¶
type Tag byte
const ( SI Tag = 0 << 5 // Small integer LI Tag = 1 << 5 // Large unsigned integer LSI Tag = 2 << 5 // Large signed integer FP Tag = 3 << 5 // Floating point SBA Tag = 4 << 5 // Small byte array LBA Tag = 5 << 5 // Large byte array OTA Tag = 6 << 5 // One-tag array KTV Tag = 7 << 5 // Key-tag-value table TNMask Tag = 0xE0 // The entire TN bitfield CNMask Tag = 0x1F // The entire CN bitfield CNLimit Tag = 32 // All valid CNs are < CNLimit )