encodable

package
v0.0.0-...-be37369 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package encodable provides low-level methods for seralising golang data structures. It aims to be fast, modular and comprehensive, valuing runtime speed over creation overhead.

Encodable is an encoder/decoder for a specific type.

The pointers passed to Encode and Decode *must* be pointers to an allocated instance of the Encodable's type, accessible by Type(). If not, expect arbritrary memory addresses to be modified, and unhelpful runtime errors. Reference types will point themselves to newly allocated types, but the reference type itself must be allocated beforehand.

Encodables typically contain static buffers, used by calls to Encode and Decode. Concurrent usage will certainly fail. If a concurrent-safe Encodable is needed, NewConcurrent is a drop-in, concurrent safe replacement.

NewEncodable creates an Encodable for a type. It takes a *Config, which is used to configure the Encodable.

Type is an encoder/decoder for type information; an encoder for reflect.Type. The primary implementation, RegisterType

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyRegistered is returned if a type is already registered.
	ErrAlreadyRegistered = errors.New("already registered")

	// ErrNotRegistered is returned if a type has not been registered.
	ErrNotRegistered = errors.New("not registered")
)

Functions

func Name

func Name(t reflect.Type) string

Name returns the name of the type and full package import path.

Types

type Array

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

Array is an Encodable for arrays

func NewArray

func NewArray(t reflect.Type, config *Config) *Array

NewArray returns a new array Encodable

func (*Array) Decode

func (e *Array) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implments Encodable

func (*Array) Encode

func (e *Array) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Array) Size

func (e *Array) Size() int

Size implements Encodable

func (*Array) String

func (e *Array) String() string

String implements Encodable

func (*Array) Type

func (e *Array) Type() reflect.Type

Type implements Encodable

type BinaryMarshaler

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

BinaryMarshaler is an Encodable for types which implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler.

func NewBinaryMarshaler

func NewBinaryMarshaler(t reflect.Type) *BinaryMarshaler

NewBinaryMarshaler returns a new BinaryMarshaler Encodable. It can internally handle a reference; i.e. time.Time's unmarshal function requires a reference, but both A type of time.Time and *time.Time will function here, as long as ptr in Encode() and Decode() is *time.Time or **time.Time respectively.

func (*BinaryMarshaler) Decode

func (e *BinaryMarshaler) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*BinaryMarshaler) Encode

func (e *BinaryMarshaler) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*BinaryMarshaler) Size

func (e *BinaryMarshaler) Size() int

Size implements Encodable

func (*BinaryMarshaler) String

func (e *BinaryMarshaler) String() string

String implements Encodable

func (*BinaryMarshaler) Type

func (e *BinaryMarshaler) Type() reflect.Type

Type implements Encodable

type Bool

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

Bool is an Encodable for bools

func (*Bool) Decode

func (e *Bool) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Bool) Encode

func (e *Bool) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Bool) Size

func (e *Bool) Size() int

Size implements Encodable

func (*Bool) String

func (e *Bool) String() string

String implements Encodable

func (*Bool) Type

func (e *Bool) Type() reflect.Type

Type implements Encodable

type Complex128

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

Complex128 is an Encodable for complex128s

func NewComplex128

func NewComplex128() *Complex128

NewComplex128 returns a new complex128 Encodable

func (*Complex128) Decode

func (e *Complex128) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Complex128) Encode

func (e *Complex128) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Complex128) Size

func (e *Complex128) Size() int

Size implemenets Sized

func (*Complex128) String

func (e *Complex128) String() string

String implements Encodable

func (*Complex128) Type

func (e *Complex128) Type() reflect.Type

Type implements Encodable

type Complex64

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

Complex64 is an Encodable for complex64s

func NewComplex64

func NewComplex64() *Complex64

NewComplex64 returns a new complex128 Encodable

func (*Complex64) Decode

func (e *Complex64) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Complex64) Encode

func (e *Complex64) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Complex64) Size

func (e *Complex64) Size() int

Size implemenets Sized

func (*Complex64) String

func (e *Complex64) String() string

String implements Encodable

func (*Complex64) Type

func (e *Complex64) Type() reflect.Type

Type implements Encodable

type Concurrent

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

Concurrent is a thread safe encodable. It functions as a drop in replacement for Encodables, keeping a cache of Encodables, only allowing a single call at a time on any one Encodable. If all cached Encodables are busy in a call, it creates a new Encodable, and calls it; It never blocks.

func NewConcurrent

func NewConcurrent(new func() Encodable) *Concurrent

NewConcurrent wraps an Encodable with Concurrent, implementing Encodable with thread safety.

func (*Concurrent) Decode

func (e *Concurrent) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Concurrent) Encode

func (e *Concurrent) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Concurrent) Size

func (e *Concurrent) Size() int

Size implements Sized

func (*Concurrent) String

func (e *Concurrent) String() string

String implements Encodable

func (*Concurrent) Type

func (e *Concurrent) Type() reflect.Type

Type implements Encodable

type Config

type Config struct {
	// Resolver is used by, and must be non-nil for, types which require type-resolution at Encode-Decode time.
	// That is, types which can reference new or unknown types (read: interface types).
	// This could conceivably differ from Encoder and Decoder, as long as the decoding Resolver can decode the encoding Resolvers output.
	// Feel free to experiment.
	Resolver Resolver

	// IncludeUnexported will include unexported struct fields in the encoded data.
	IncludeUnexported bool

	// If StructTag is set, only struct fields with the given tag will be encoded
	StructTag string
}

Config contains settings and information for the generation of a new Encodable. Some Encodables do nothing with Config, and some require information from it.

Config *must* be the same for Encoder and Decoder.

func (*Config) String

func (c *Config) String() string

String returns a string unique to the given configuration. Format is Config(options, StructTag: <StructTag>, Resolver: <Resolver>). Options are - u for IncludeUnexported

type Encodable

type Encodable interface {
	// Type returns the type that the Encodable encodes.
	// ptr in Encode() and Decode() *must* be a pointer to an object of this type.
	// It is thread safe.
	Type() reflect.Type

	// Encode writes the encoded form of the object at ptr to w.
	Encode(ptr unsafe.Pointer, w io.Writer) error

	// Decode reads the encoded form from r into the object at ptr.
	// Decodes will only read what Encode wrote.
	Decode(ptr unsafe.Pointer, r io.Reader) error

	// Size returns the maximum encoded size of the Encodable.
	// If Size returns <0, size is undefined.
	// It is thread safe.
	Size() int

	// String returns a string showing the Encodable's structure.
	// () shows a little information about the encoder, such as the type it encodes or relavent settings.
	// {} denotes sub-Encoders; encoders that encode parts of a larger Encodable.
	// Comparing results from String is an effecive way of equality checking.
	// It is thread safe.
	fmt.Stringer // String() string
}

Encodable is an Encoder/Decoder for a specific type.

Encoders are not assumed to be thread safe. Encode() and Decode() often share static buffers for the sake of performance, but this comes at the cost of thread safety. Concurrent calls to either Encode() or Decode() will almost certainly result in complete failure. Use NewConcurrent if concurrency is needed.

Encodables should return two kinds of error. encio.IOError and encio.Error for io and corrupted data errors, and Error for encoding errors. See encs/encio

func New

func New(t reflect.Type, config *Config) Encodable

New returns a new Encodable for encoding the type t. config contains settings and information for the generation of the Encodable. In many cases, it can be nil for sane defaults, however some Enodable types require information from the config.

func NewBool

func NewBool() Encodable

NewBool returns a new bool Encodable

func NewInterface

func NewInterface(t reflect.Type, config *Config) Encodable

NewInterface returns a new interface Encodable

func NewPointer

func NewPointer(t reflect.Type, config *Config) Encodable

NewPointer returns a new Pointer Encodable.

type Float32

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

Float32 is an Encodable for float32s

func NewFloat32

func NewFloat32() *Float32

NewFloat32 returns a new float32 Encodable.

func (*Float32) Decode

func (e *Float32) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Float32) Encode

func (e *Float32) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Float32) Size

func (e *Float32) Size() int

Size implemenets Sized

func (*Float32) String

func (e *Float32) String() string

String implements Encodable

func (*Float32) Type

func (e *Float32) Type() reflect.Type

Type implements Encodable

type Float64

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

Float64 is an Encodable for float64s

func NewFloat64

func NewFloat64() *Float64

NewFloat64 returns a new float64 Encodable.

func (*Float64) Decode

func (e *Float64) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Float64) Encode

func (e *Float64) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Float64) Size

func (e *Float64) Size() int

Size implemenets Sized

func (*Float64) String

func (e *Float64) String() string

String implements Encodable

func (*Float64) Type

func (e *Float64) Type() reflect.Type

Type implements Encodable

type Int

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

Int is an Encodable for intss

func NewInt

func NewInt() *Int

NewInt returns a new int Encodable

func (*Int) Decode

func (e *Int) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Int) Encode

func (e *Int) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Int) Size

func (e *Int) Size() int

Size implements Encodable

func (*Int) String

func (e *Int) String() string

String implements Encodable

func (*Int) Type

func (e *Int) Type() reflect.Type

Type implements Encodable

type Int16

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

Int16 is an Encodable for int16s

func NewInt16

func NewInt16() *Int16

NewInt16 returns a new int16 Encodable

func (*Int16) Decode

func (e *Int16) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Int16) Encode

func (e *Int16) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Int16) Size

func (e *Int16) Size() int

Size implements Encodable

func (*Int16) String

func (e *Int16) String() string

String implements Encodable

func (*Int16) Type

func (e *Int16) Type() reflect.Type

Type implements Encodable

type Int32

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

Int32 is an Encodable for int32s

func NewInt32

func NewInt32() *Int32

NewInt32 returns a new int32 Encodable

func (*Int32) Decode

func (e *Int32) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Int32) Encode

func (e *Int32) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Int32) Size

func (e *Int32) Size() int

Size implements Encodable

func (*Int32) String

func (e *Int32) String() string

String implements Encodable

func (*Int32) Type

func (e *Int32) Type() reflect.Type

Type implements Encodable

type Int64

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

Int64 is an Encodable for int64s

func NewInt64

func NewInt64() *Int64

NewInt64 returns a new int64 Encodable

func (*Int64) Decode

func (e *Int64) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Int64) Encode

func (e *Int64) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Int64) Size

func (e *Int64) Size() int

Size implements Encodable

func (*Int64) String

func (e *Int64) String() string

String implements Encodable

func (*Int64) Type

func (e *Int64) Type() reflect.Type

Type implements Encodable

type Int8

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

Int8 is an Encodable for int8s

func NewInt8

func NewInt8() *Int8

NewInt8 returns a new int8 Encodable

func (*Int8) Decode

func (e *Int8) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Int8) Encode

func (e *Int8) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Int8) Size

func (e *Int8) Size() int

Size implements Encodable

func (*Int8) String

func (e *Int8) String() string

String implements Encodable

func (*Int8) Type

func (e *Int8) Type() reflect.Type

Type implements Encodable

type Interface

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

Interface is an Encodable for interfaces

func (*Interface) Decode

func (e *Interface) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Interface) Encode

func (e *Interface) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Interface) Size

func (e *Interface) Size() int

Size implements Encodable

func (*Interface) String

func (e *Interface) String() string

String implements Encodable

func (*Interface) Type

func (e *Interface) Type() reflect.Type

Type implements Encodable

type Map

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

Map is an Encodable for maps

func NewMap

func NewMap(t reflect.Type, config *Config) *Map

NewMap returns a new map Encodable

func (*Map) Decode

func (e *Map) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Map) Encode

func (e *Map) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Map) Size

func (e *Map) Size() int

Size implements Encodable

func (*Map) String

func (e *Map) String() string

String implements Encodable

func (*Map) Type

func (e *Map) Type() reflect.Type

Type implements Encodable

type Memory

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

Memory is an encoder that throws type-safety out the window (as if the rest of this library wasn't enough). Initialised with NewMemory(size), it reads/writes directly to the memory at the given address with no internal buffering. Extreme care must be taken, errors from Memory can be difficult to read, let alone helpful in debugging, and are often in the form of panics, or worse still, the silent destruction of the universe.

func NewMemory

func NewMemory(size int) *Memory

NewMemory returns a new Memory encoder

func (*Memory) Decode

func (e *Memory) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Decodable

func (*Memory) Encode

func (e *Memory) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Memory) Size

func (e *Memory) Size() int

Size implemenets Encodable

func (*Memory) String

func (e *Memory) String() string

String implements Encodable

func (*Memory) Type

func (e *Memory) Type() reflect.Type

Type implements Encodable

type Pointer

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

Pointer encodes pointers to concrete types.

func (*Pointer) Decode

func (e *Pointer) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Pointer) Encode

func (e *Pointer) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Pointer) Size

func (e *Pointer) Size() int

Size implements Sized

func (*Pointer) String

func (e *Pointer) String() string

String implements Encodable

func (*Pointer) Type

func (e *Pointer) Type() reflect.Type

Type implements Encodable

type RegisterResolver

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

RegisterResolver is a registration-based TypeResolver. All types to be encoded and decoded must be registered with Register(), with the exception of int*, uint*, float*, complex*, string, bool, time.Time, and time.Duration, which are pre-registered. It is thread safe.

func NewRegisterResolver

func NewRegisterResolver(hasher hash.Hash64) *RegisterResolver

NewRegisterResolver returns a new RegisterResolver TypeResolver

func (*RegisterResolver) Decode

func (rr *RegisterResolver) Decode(expected reflect.Type, r io.Reader) (reflect.Type, error)

Decode implements TypeResolver

func (*RegisterResolver) Encode

func (rr *RegisterResolver) Encode(ty reflect.Type, w io.Writer) error

Encode implements TypeResolver

func (*RegisterResolver) Register

func (rr *RegisterResolver) Register(T interface{}) error

Register registers T, &T, []T, and *T if T is a pointer.

func (*RegisterResolver) Size

func (rr *RegisterResolver) Size() int

Size implements TypeResolver

type Resolver

type Resolver interface {
	// Encode encodes the type t, writing to w.
	Encode(t reflect.Type, w io.Writer) error

	// Decode reads an encoded type, returning it.
	// Decode must only read the same number of bytes written by Encode().
	//
	// In the case of decoding into interfaces, it might be expected that the received type is the same as the existing type in the interface.
	// in this case, it might be sufficent to simply check if the types are equal, relying on the expected type as an existing reflect.Type instance.
	// In this case, bool or (bool, error) would be sufficent return values.
	//
	// Other implementations might attempt to completely resolve a reflect.Type value from encoded data,
	// in which case expected is an uneccecary argument.
	//
	// In the case of registration-based Resolvers, if the interface contains the type that's being sent,
	// it can be fortuitus to register the expected type, as it might not have been registered before.
	//
	// I belive this function format is a good happy medium to allow for these different implementations,
	// however, Resolvers should always be certain that the type returned from decode is either the same as what was given to Encode, or nil.
	// Incorrect types will cause panics, or worse, incorrect memory manipulation.
	Decode(expected reflect.Type, r io.Reader) (reflect.Type, error)

	// Size returns the number of bytes the Resolver will read and write to the buffer.
	// It can write less, but never more. If length is undefined, Size should return a negative.
	Size() int
}

Resolver is a method for encoding types.

type Slice

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

Slice is an Encodable for slices

func NewSlice

func NewSlice(t reflect.Type, config *Config) *Slice

NewSlice returns a new slice Encodable

func (*Slice) Decode

func (e *Slice) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implemenets Encodable. Encoded 0-len and nil slices both have the effect of setting the decoded slice's len and cap to 0. nil-ness of the slice being decoded into is retained.

func (*Slice) Encode

func (e *Slice) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable.Encode. Encoded 0-len and nil slices both have the effect of setting the decoded slice's len and cap to 0. nil-ness of the slice being decoded into is retained.

func (*Slice) Size

func (e *Slice) Size() int

Size implemenets Encodable

func (*Slice) String

func (e *Slice) String() string

String implements Encodable

func (*Slice) Type

func (e *Slice) Type() reflect.Type

Type implements Encodable

type Source

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

Source is a cache of Encodables. Encodables are only created once, with subsequent calls to GetEncodable returning the previously created encodable.

func NewSource

func NewSource(config *Config, new func(reflect.Type, *Config) Encodable) *Source

NewSource returns a Source with the given config and new function.

func (*Source) GetEncodable

func (s *Source) GetEncodable(ty reflect.Type) Encodable

GetEncodable returns an encodable for the given type, as created by the new function passed to NewSource.

type String

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

String is an Encodable for strings

func NewString

func NewString() *String

NewString returns a new string Encodable

func (*String) Decode

func (e *String) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implemenets Encodable

func (*String) Encode

func (e *String) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implemenets Encodable

func (*String) Size

func (e *String) Size() int

Size implemenets Encodable

func (*String) String

func (e *String) String() string

String implements Encodable

func (*String) Type

func (e *String) Type() reflect.Type

Type implements Encodable

type Struct

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

Struct is an Encodable for structs

func NewStruct

func NewStruct(t reflect.Type, config *Config) *Struct

NewStruct returns a new struct Encodable

func (Struct) Decode

func (e Struct) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (Struct) Encode

func (e Struct) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (Struct) Size

func (e Struct) Size() (size int)

Size implements Sized

func (*Struct) String

func (e *Struct) String() string

String implements Encodable

func (Struct) Type

func (e Struct) Type() reflect.Type

Type implements Encodable

type Uint

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

Uint is an Encodable for uints

func NewUint

func NewUint() *Uint

NewUint returns a new uint Encodable

func (*Uint) Decode

func (e *Uint) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uint) Encode

func (e *Uint) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uint) Size

func (e *Uint) Size() int

Size implements Encodable

func (*Uint) String

func (e *Uint) String() string

String implements Encodable

func (*Uint) Type

func (e *Uint) Type() reflect.Type

Type implements Encodable

type Uint16

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

Uint16 is an Encodable for uint16s

func NewUint16

func NewUint16() *Uint16

NewUint16 returns a new uint16 Encodable

func (*Uint16) Decode

func (e *Uint16) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uint16) Encode

func (e *Uint16) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uint16) Size

func (e *Uint16) Size() int

Size implements Encodable

func (*Uint16) String

func (e *Uint16) String() string

String implements Encodable

func (Uint16) Type

func (e Uint16) Type() reflect.Type

Type implements Encodable

type Uint32

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

Uint32 is an Encodable for uint32s

func NewUint32

func NewUint32() *Uint32

NewUint32 returns a new uint32 Encodable

func (*Uint32) Decode

func (e *Uint32) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uint32) Encode

func (e *Uint32) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uint32) Size

func (e *Uint32) Size() int

Size implements Encodable

func (*Uint32) String

func (e *Uint32) String() string

String implements Encodable

func (*Uint32) Type

func (e *Uint32) Type() reflect.Type

Type implements Encodable

type Uint64

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

Uint64 is an Encodable for uint64s

func NewUint64

func NewUint64() *Uint64

NewUint64 returns a new uint64 Encodable

func (*Uint64) Decode

func (e *Uint64) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uint64) Encode

func (e *Uint64) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uint64) Size

func (e *Uint64) Size() int

Size implements Encodable

func (*Uint64) String

func (e *Uint64) String() string

String implements Encodable

func (*Uint64) Type

func (e *Uint64) Type() reflect.Type

Type implements Encodable

type Uint8

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

Uint8 is an Encodable for uint8s

func NewUint8

func NewUint8() *Uint8

NewUint8 returns a new uint8 Encodable

func (*Uint8) Decode

func (e *Uint8) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uint8) Encode

func (e *Uint8) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uint8) Size

func (e *Uint8) Size() int

Size implements Encodable

func (*Uint8) String

func (e *Uint8) String() string

String implements Encodable

func (*Uint8) Type

func (e *Uint8) Type() reflect.Type

Type implements Encodable

type Uintptr

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

Uintptr is an Encodable for uintptrs

func NewUintptr

func NewUintptr() *Uintptr

NewUintptr returns a new uintptr Encodable

func (*Uintptr) Decode

func (e *Uintptr) Decode(ptr unsafe.Pointer, r io.Reader) error

Decode implements Encodable

func (*Uintptr) Encode

func (e *Uintptr) Encode(ptr unsafe.Pointer, w io.Writer) error

Encode implements Encodable

func (*Uintptr) Size

func (e *Uintptr) Size() int

Size implements Encodable

func (*Uintptr) String

func (e *Uintptr) String() string

String implements Encodable

func (*Uintptr) Type

func (e *Uintptr) Type() reflect.Type

Type implements Encodable

Jump to

Keyboard shortcuts

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