Documentation ¶
Overview ¶
Package binary provide functionality for encoding Go types into OPC UA binary representation as defined by [IEC-62541](https://webstore.iec.ch/webstore/webstore.nsf/mysearchajax?Openform&key=62541). Encode and decode functionality only aims to fully handle types that are defined in the uatype package, and can not be expected to handle all Go types. As an example, int and uint types without a bit size suffix are deliberately not handled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidBitLength = errors.New("bit length not in range 1-8") ErrInvalidLength = errors.New("length don't match length field value") ErrInvalidTag = errors.New("invalid struct tag") ErrNotSetable = errors.New("value must be a pointer") ErrUnknownType = errors.New("can not handle type") )
Common errors that may be returned as the cause for EncoderError and DecoderError.
Functions ¶
func Marshal ¶
Marshal encodes v into the OPC UA Binary Encoding format, and returns it as a slice of bytes.
func SetDebugLogger ¶
SetDebugLogger sets a debug logger for this package.
Types ¶
type BitLengther ¶
type BitLengther interface {
BitLength() int
}
BitLengther is implemented by types that should be encoded into, or has been decoded from, a certain number of bits.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder reads and decodes OPC UA Binary content from an input stream.
type DecoderError ¶
type DecoderError struct {
// contains filtered or unexported fields
}
DecoderError provides a way of getting the logical path to where in a nested data structure a decoder error occurred.
func (DecoderError) Error ¶
func (err DecoderError) Error() string
Error returns a human readable description of the error.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder writes OPC UA Binary content to an output stream.
func NewEncoder ¶
NewEncoder takes a writer object where OPC UA data will be written on calls to Encode.
func (*Encoder) BytesWritten ¶
BytesWritten returns the number of bytes written since the BinaryEncoder was initialized.
type EncoderError ¶
type EncoderError struct {
// contains filtered or unexported fields
}
EncoderError provides a way of getting the logical path to where in a nested data structure an encoder error occurred.
func (EncoderError) Error ¶
func (err EncoderError) Error() string
Error returns a human readable description of the error.