serialize

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package serialize provides a Serializer interface with implementations that encode and decode message data in various ways.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryData

type BinaryData []byte

Binary data follows a convention for conversion to JSON strings.

A byte array is converted to a JSON string as follows:

1. convert the byte array to a Base64 encoded (host language) string 2. prepend the string with a \0 character 3. serialize the string to a JSON string

func (BinaryData) MarshalJSON

func (b BinaryData) MarshalJSON() ([]byte, error)

func (*BinaryData) UnmarshalJSON

func (b *BinaryData) UnmarshalJSON(v []byte) error

type CBORSerializer

type CBORSerializer struct{}

CBORSerializer is an implementation of Serializer that handles serializing and deserializing cbor encoded payloads.

func (*CBORSerializer) Deserialize

func (s *CBORSerializer) Deserialize(data []byte) (wamp.Message, error)

Deserialize decodes a cbor payload into a Message.

func (*CBORSerializer) Serialize

func (s *CBORSerializer) Serialize(msg wamp.Message) ([]byte, error)

Serialize encodes a Message into a cbor payload.

type JSONSerializer

type JSONSerializer struct{}

JSONSerializer is an implementation of Serializer that handles serializing and deserializing json encoded payloads.

func (*JSONSerializer) Deserialize

func (s *JSONSerializer) Deserialize(data []byte) (wamp.Message, error)

Deserialize decodes a json payload into a Message.

func (*JSONSerializer) Serialize

func (s *JSONSerializer) Serialize(msg wamp.Message) ([]byte, error)

Serialize encodes a Message into a json payload.

type MessagePackSerializer

type MessagePackSerializer struct{}

MessagePackSerializer is an implementation of Serializer that handles serializing and deserializing msgpack encoded payloads.

func (*MessagePackSerializer) Deserialize

func (s *MessagePackSerializer) Deserialize(data []byte) (wamp.Message, error)

Deserialize decodes a msgpack payload into a Message.

func (*MessagePackSerializer) Serialize

func (s *MessagePackSerializer) Serialize(msg wamp.Message) ([]byte, error)

Serialize encodes a Message into a msgpack payload.

type Serialization

type Serialization int

Serialization indicates the data serialization format used in a WAMP session

const (
	// Use JSON-encoded strings as a payload.
	JSON Serialization = iota
	// Use msgpack-encoded strings as a payload.
	MSGPACK
	// Use CBOR encoding as a payload
	CBOR
)

type Serializer

type Serializer interface {
	Serialize(wamp.Message) ([]byte, error)
	Deserialize([]byte) (wamp.Message, error)
}

Serializer is the interface implemented by an object that can serialize and deserialize WAMP messages

Jump to

Keyboard shortcuts

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