ocf

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(message *pool.Message) string

Dump a COAP message to a string. If parsing fails, the error is appended.

func DumpHeader

func DumpHeader(m *pool.Message) string

DumpHeader dumps the basic COAP message details to a string.

func DumpPayload

func DumpPayload(m *pool.Message) (string, error)

DumpPayload dumps the COAP message payload to a string.

Types

type RawCodec

type RawCodec struct {
	EncodeMediaType  message.MediaType
	DecodeMediaTypes []message.MediaType
}

RawCodec performs no encoding/decoding but it propagates/validates the CoAP content format/media type.

func MakeRawVNDOCFCBORCodec

func MakeRawVNDOCFCBORCodec() RawCodec

MakeRawVNDOCFCBORCodec creates a RawVNDOCFCBORCodec codec, which performs no encoding/decoding, but propagates/validates the CoAP content format/media type.

func (RawCodec) ContentFormat

func (c RawCodec) ContentFormat() message.MediaType

ContentFormat propagates the CoAP media type

func (RawCodec) Decode

func (c RawCodec) Decode(m *pool.Message, v interface{}) error

Decode validates the content format and propagates the payload to v as *[]byte without any conversions.

func (RawCodec) DecodeContentFormat

func (c RawCodec) DecodeContentFormat() []message.MediaType

DecodeContentFormat propagates the CoAP media type

func (RawCodec) Encode

func (c RawCodec) Encode(v interface{}) ([]byte, error)

Encode propagates the payload without any conversions.

type VNDOCFCBORCodec

type VNDOCFCBORCodec struct{}

VNDOCFCBORCodec encodes/decodes according to the CoAP content format/media type.

func (VNDOCFCBORCodec) ContentFormat

func (VNDOCFCBORCodec) ContentFormat() message.MediaType

ContentFormat used for encoding.

func (VNDOCFCBORCodec) Decode

func (VNDOCFCBORCodec) Decode(m *pool.Message, v interface{}) error

Decode the CBOR payload of a COAP message.

func (VNDOCFCBORCodec) Encode

func (VNDOCFCBORCodec) Encode(v interface{}) ([]byte, error)

Encode encodes v and returns bytes.

Jump to

Keyboard shortcuts

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