sdata

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalSD

func MarshalSD(sd interface{}) []byte

MarshalSD encode a structured data to a []byte

func NextHeader

func NextHeader(data []byte) (header string, ret []byte, err error)

NextHeader try to decode a Structured Data header from a []byte

func NextNonSpace

func NextNonSpace(data []byte) (ret []byte, err error)

NextNonSpace try to decode a Structured Data part from a []byte

func NextSDName

func NextSDName(data []byte) (name string, ret []byte, err error)

NextSDName try to decode a Structured Data Name from a []byte

func NextSDValue

func NextSDValue(data []byte) (value string, ret []byte, err error)

NextSDValue try to decode a Structured Data Value from a []byte

func RegisterGroup

func RegisterGroup(sdids ...SDID)

RegisterGroup is a wrapper around Register

func UnmarshalSD

func UnmarshalSD(data []byte, v interface{}) error

UnmarshalSD decode a []byte to a golang struct

Types

type Foundable

type Foundable interface {
	String() string
	Found([]byte) (StructuredData, bool)
}

Foundable is the minimal part of the SDID interface for testing

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

InvalidUnmarshalError …

func (*InvalidUnmarshalError) Error

func (e *InvalidUnmarshalError) Error() string

type InvalidValueError

type InvalidValueError struct {
	Value reflect.Value
}

InvalidValueError …

func (*InvalidValueError) Error

func (e *InvalidValueError) Error() string

type List

type List []StructuredData

List represent a list of Structured Data

func EmptyList

func EmptyList() List

EmptyList return an empty []StructuredData

func (List) Add

func (listSD List) Add(data ...StructuredData) List

Add append data to a list of structured data

func (List) Marshal5424

func (listSD List) Marshal5424() ([]byte, error)

Marshal5424 encode a Structured Data to syslog 5424 format

func (List) MarshalText

func (listSD List) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaller

func (List) String

func (listSD List) String() (s string)

type MarshalerError

type MarshalerError struct {
	Type reflect.Type
	Err  error
}

MarshalerError …

func (*MarshalerError) Error

func (e *MarshalerError) Error() string

type SDID

type SDID interface {
	SDIDLight
	Found([]byte) (StructuredData, bool)
	encoding.TextMarshaler
}

SDID expose a way to handle the detection of a Structured Data

func Register

func Register(s SDID) SDID

Register add an new SDID to a global registry

type SDIDLight

type SDIDLight interface {
	String() string
	IsIANA() bool
	GetPEN() uint64
}

SDIDLight expose a minimal way to handle Structured Data identifier

type SDTest

type SDTest interface {
	DoTest(sdid Foundable) error
}

SDTest describe the common interface of any test on Structured Data

func TestInvalidMarshal

func TestInvalidMarshal(Obj StructuredData, Err error) SDTest

TestInvalidMarshal define a test a non Marshallable Structured Data

func TestInvalidUnmarshal

func TestInvalidUnmarshal(Orig string) SDTest

TestInvalidUnmarshal define a test a non Unmarshallable Structured Data

func TestValid

func TestValid(Orig string, Obj StructuredData, Enc string) SDTest

TestValid define a test for valid Structured Data

type StructuredData

type StructuredData interface {
	SDID() SDID
	Marshal5424() ([]byte, error)
}

StructuredData expose a way to encode a structured data

func GenericSD

func GenericSD(i SDIDLight) StructuredData

GenericSD create a generic structured Data

func Parse

func Parse(data []byte) (StructuredData, bool)

Parse decode a []byte to a Structured Data

type UnsupportedTypeError

type UnsupportedTypeError struct {
	Type reflect.Type
}

UnsupportedTypeError …

func (*UnsupportedTypeError) Error

func (e *UnsupportedTypeError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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