def

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: Unlicense, Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package def contains interfaces defining the basic types in duo and other global information

Index

Constants

This section is empty.

Variables

View Source
var Dbg = NewDebug()

Dbg is a variable available to any importing this package to enabling debug printing for error status prints and miscellaneous

View Source
var StringCodingTypes = []string{
	"byte",
	"string",
	"decimal",
	"hex",
	"base32",
	"base58",
	"base58check",
	"base64",
}

StringCodingTypes is the types of encoding available, append only to add new ones for compatibility

Functions

This section is empty.

Types

type Array

type Array interface {
	Elem(int) interface{}                 // returns a buffer containing the numbered array element
	Len() int                             // returns the length of the array
	SetElem(int, interface{}) interface{} // loads the buffer at the given index
}

Array is an interface for working with data that can be split into multiple identical typed subunits.

type Buffer

type Buffer interface {
	Buf() interface{}        // returns the pointer to the slice it represents
	Copy(interface{}) Buffer // duplicates a passed buffer
	Free() Buffer            // dereferences the buffer
	Len() int                // returns the byte length of the buffer
	Link(Buffer) Buffer      // copies the pointer of another Buffer
	OfLen(int) Buffer        // creates a new empty buffer of a given size
	Null() Buffer            // zeroes out the buffer
	Rand(...int) Buffer      // loads the buffer with random bytes
	Coding() Coding          // Defines  output encoding for the stringer
	Status() Status          // Embeds error handling
	Array() Array            // Allows the addressing of a buffer as a list of uniform sized subunits
	String() (S string)      // renders a string from the buffer
}

Buffer is a generic interface for structs that contain *[]byte elements

type Coding

type Coding interface {
	Get() string       // returns the current coding type
	Set(string) Coding // sets the coding type
	List() []string    // returns an array of strings representing available coding types
}

Coding is an interface for data types that have multiple string output formats

type Debug

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

Debug is an object that can be embedded into types to provide a debug print service for error status reporting

func NewDebug

func NewDebug() *Debug

NewDebug creates a new debug object

func (*Debug) Disable

func (r *Debug) Disable() interface{}

Disable turns off debug printing

func (*Debug) Enable

func (r *Debug) Enable() interface{}

Enable turns on debug printing

func (*Debug) Enabled

func (r *Debug) Enabled() bool

Enabled returns true if debug printing is enabled

func (*Debug) Print

func (r *Debug) Print(s ...interface{}) interface{}

Print prints out debugging information

type ErrorStatus

type ErrorStatus struct {
	Err error
}

ErrorStatus is a status getter/setter for controlling the error string

func (*ErrorStatus) Error

func (r *ErrorStatus) Error() string

Error returns the error field of a Status

func (*ErrorStatus) Set

func (r *ErrorStatus) Set(s ...interface{}) interface{}

Set the status string/error

func (*ErrorStatus) Unset

func (r *ErrorStatus) Unset() interface{}

Unset the status string/error

type Status

type Status interface {
	Set(...interface{}) interface{} // sets the string that is returned by Error()
	Unset() interface{}             // clears error to represent the nominal state
	Error() string                  // returns the error field of a Status
}

Status is an extension of the Error interface that also adds getting and setting

type StringCoding

type StringCoding int

StringCoding is a coding type for converting data to strings

func (StringCoding) Get

func (r StringCoding) Get() string

Get returns the current coding type

func (StringCoding) List

func (r StringCoding) List() (R []string)

List returns an array of strings representing available coding

func (StringCoding) Set

func (r StringCoding) Set(s string) Coding

Set sets the coding type

Jump to

Keyboard shortcuts

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