ocf

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 6 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownContentFormat = errors.New("unknown content format")
	ErrEmptyBody            = errors.New("unexpected empty body")
	ErrReadBody             = errors.New("cannot read body")
)

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