serialize

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 8 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 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
)

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