structured

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = map[string]TypeMaker{
	"integer": MakeInteger,
	"date":    MakeDate,
	"ip":      MakeIPAddr,
	"ipv4":    MakeIPAddr,
	"ipv6":    MakeIPAddr,
}

Functions

func Revert

func Revert(inp []byte, l uint) []byte

Types

type BitArray

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

func MakeBitArray

func MakeBitArray(length uint) *BitArray

func MakeBitArrayFromBytes

func MakeBitArrayFromBytes(bytes []byte, length uint) (*BitArray, error)

func (*BitArray) Append

func (b *BitArray) Append(ba *BitArray) error

func (*BitArray) AsString

func (b *BitArray) AsString() string

func (*BitArray) Bytes

func (b *BitArray) Bytes() []byte

func (*BitArray) Copy

func (b *BitArray) Copy() *BitArray

func (*BitArray) Equals

func (b *BitArray) Equals(ba *BitArray) bool

func (*BitArray) Extract

func (b *BitArray) Extract(offset, length uint) (*BitArray, error)

func (*BitArray) Length

func (b *BitArray) Length() uint

func (*BitArray) Update

func (b *BitArray) Update(ba *BitArray, offset uint) error

type CompositeListType

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

func (*CompositeListType) Copy

func (d *CompositeListType) Copy() CompositeType

func (*CompositeListType) Decode

func (d *CompositeListType) Decode(b *BitArray) error

func (*CompositeListType) DecodeSubtype

func (d *CompositeListType) DecodeSubtype(i int, b *BitArray) error

func (*CompositeListType) Encode

func (d *CompositeListType) Encode() (*BitArray, error)

func (*CompositeListType) EncodeSubtype

func (d *CompositeListType) EncodeSubtype(i int) (*BitArray, error)

func (*CompositeListType) Equals

func (d *CompositeListType) Equals(dr CompositeType) bool

func (*CompositeListType) Get

func (d *CompositeListType) Get(i int) (Type, error)

func (*CompositeListType) IsValid

func (d *CompositeListType) IsValid() []bool

func (*CompositeListType) Length

func (d *CompositeListType) Length(i int) (uint, error)

func (*CompositeListType) Marshal

func (d *CompositeListType) Marshal(format string) (interface{}, error)

func (*CompositeListType) Offset

func (d *CompositeListType) Offset(i int) (uint, error)

func (*CompositeListType) SetSubtypes

func (d *CompositeListType) SetSubtypes(types []Type)

func (*CompositeListType) Subtypes

func (d *CompositeListType) Subtypes() []Type

func (*CompositeListType) Unmarshal

func (d *CompositeListType) Unmarshal(format string, value interface{}) error

type CompositeListTypeIf

type CompositeListTypeIf interface {
	Subtypes() []Type
}

type CompositeType

type CompositeType interface {

	// helper functions to copy, check equality and validity etc...
	IsValid() []bool
	Equals(CompositeType) bool
	Copy() CompositeType

	// get info about subtypes
	Offset(int) (uint, error)
	Length(int) (uint, error)
	Get(int) (Type, error)

	// marshal and unmarshal to/from a given format
	Marshal(format string) (interface{}, error)
	Unmarshal(format string, value interface{}) error

	// encode and decode a composite type to/from bitarrays
	Decode(*BitArray) error
	Encode() (*BitArray, error)
	EncodeSubtype(int) (*BitArray, error)
	DecodeSubtype(int, *BitArray) error
}

func DPS

func DPS(c CompositeType, key []byte) (CompositeType, error)

func DPSH

func DPSH(c CompositeType, key []byte) (CompositeType, error)

func MakeCompositeListType

func MakeCompositeListType() CompositeType

func MakeDate

func MakeDate(interface{}) (CompositeType, error)

func MakeIPAddr

func MakeIPAddr(params interface{}) (CompositeType, error)

func MakeInteger

func MakeInteger(params interface{}) (CompositeType, error)

func PS

func PS(c CompositeType, key []byte) (CompositeType, error)

func PSH

func PSH(c CompositeType, key []byte) (CompositeType, error)

type Date

type Date struct {
	CompositeListType
}

func (*Date) Copy

func (d *Date) Copy() CompositeType

func (*Date) IsValid

func (d *Date) IsValid() []bool

func (*Date) Marshal

func (d *Date) Marshal(format string) (interface{}, error)

func (*Date) Unmarshal

func (d *Date) Unmarshal(format string, data interface{}) error

type DateElement

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

func (*DateElement) Decode

func (h *DateElement) Decode(b *BitArray) error

func (*DateElement) Encode

func (h *DateElement) Encode() (*BitArray, error)

func (*DateElement) Equals

func (h *DateElement) Equals(t Type) bool

func (*DateElement) Field

func (h *DateElement) Field() byte

func (*DateElement) IsValid

func (h *DateElement) IsValid() bool

func (*DateElement) Length

func (h *DateElement) Length() uint

func (*DateElement) Order

func (h *DateElement) Order() uint

func (*DateElement) SetRange

func (h *DateElement) SetRange(min, max int64) error

func (*DateElement) Value

func (h *DateElement) Value() int64

type DateElementIf

type DateElementIf interface {
	Value() int64
	Length() uint
	Order() uint
	SetRange(int64, int64) error
	Field() byte
}

type Day

type Day struct {
	DateElement
}

func (*Day) Copy

func (d *Day) Copy() Type

type Elements

type Elements []Type

Used for sorting date elements by their order

func (Elements) Len

func (e Elements) Len() int

func (Elements) Less

func (e Elements) Less(i, j int) bool

func (Elements) Swap

func (e Elements) Swap(i, j int)

type FormatField

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

type Hour

type Hour struct {
	DateElement
}

func (*Hour) Copy

func (h *Hour) Copy() Type

type IPAddr

type IPAddr struct {
	CompositeListType
	// contains filtered or unexported fields
}

func (*IPAddr) Copy

func (ip *IPAddr) Copy() CompositeType

func (*IPAddr) Marshal

func (ip *IPAddr) Marshal(format string) (interface{}, error)

func (*IPAddr) Unmarshal

func (ip *IPAddr) Unmarshal(format string, data interface{}) error

type IPAddress

type IPAddress struct {
	IPElement
}

func (*IPAddress) Copy

func (h *IPAddress) Copy() Type

func (*IPAddress) IsValid

func (h *IPAddress) IsValid() bool

type IPElement

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

func (*IPElement) Decode

func (h *IPElement) Decode(b *BitArray) error

func (*IPElement) Encode

func (h *IPElement) Encode() (*BitArray, error)

func (*IPElement) Equals

func (h *IPElement) Equals(t Type) bool

func (*IPElement) Length

func (h *IPElement) Length() uint

func (*IPElement) Value

func (h *IPElement) Value() []byte

type IPElementIf

type IPElementIf interface {
	Value() []byte
	Length() uint
}

type Integer

type Integer struct {
	CompositeListType
	// contains filtered or unexported fields
}

func (*Integer) Copy

func (d *Integer) Copy() CompositeType

func (*Integer) Marshal

func (r *Integer) Marshal(format string) (interface{}, error)

func (*Integer) Unmarshal

func (r *Integer) Unmarshal(format string, value interface{}) error

type IntegerField

type IntegerField struct {
	Max   int64
	Min   int64
	Value int64
	// contains filtered or unexported fields
}

func MakeIntegerField

func MakeIntegerField(min, max, value int64) (*IntegerField, error)

func (*IntegerField) Copy

func (r *IntegerField) Copy() Type

func (*IntegerField) Decode

func (r *IntegerField) Decode(b *BitArray) error

func (*IntegerField) Encode

func (r *IntegerField) Encode() (*BitArray, error)

func (*IntegerField) Equals

func (r *IntegerField) Equals(t Type) bool

func (*IntegerField) IsValid

func (r *IntegerField) IsValid() bool

func (*IntegerField) Length

func (r *IntegerField) Length() uint

type Minute

type Minute struct {
	DateElement
}

func (*Minute) Copy

func (h *Minute) Copy() Type

type Month

type Month struct {
	DateElement
}

func (*Month) Copy

func (m *Month) Copy() Type

type NanoSecond

type NanoSecond struct {
	DateElement
}

func (*NanoSecond) Copy

func (n *NanoSecond) Copy() Type

type Second

type Second struct {
	DateElement
}

func (*Second) Copy

func (s *Second) Copy() Type

type TimeZone

type TimeZone struct {
	DateElement
}

func (*TimeZone) Copy

func (t *TimeZone) Copy() Type

func (*TimeZone) Value

func (h *TimeZone) Value() int64

type Type

type Type interface {
	IsValid() bool
	Decode(*BitArray) error
	Encode() (*BitArray, error)
	Length() uint
	Copy() Type
	Equals(Type) bool
}

func MakeDay

func MakeDay(value int64) Type

func MakeHour

func MakeHour(value int64) Type

func MakeIPAddress

func MakeIPAddress(value []byte, mask uint) Type

func MakeMinute

func MakeMinute(value int64) Type

func MakeMonth

func MakeMonth(value int64) Type

func MakeNanoSecond

func MakeNanoSecond(value int64) Type

func MakeSecond

func MakeSecond(value int64) Type

func MakeTimeZone

func MakeTimeZone(value int64) Type

func MakeYear

func MakeYear(value int64) Type

type TypeMaker

type TypeMaker func(interface{}) (CompositeType, error)

type Year

type Year struct {
	DateElement
}

func (*Year) Copy

func (y *Year) Copy() Type

Jump to

Keyboard shortcuts

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