transmit

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: MIT Imports: 3 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FragmentSizeLength is the length of the encoded size of a message
	FragmentSizeLength = 4
)

Functions

func DecodeRead

func DecodeRead(conn net.Conn, obj Serializable) (err error)

DecodeRead tries to decode a serialized object that was encoded via the Iterum defaults as described in `transmit.Encode` and Read from the passed connection

func EncodeSend

func EncodeSend(conn net.Conn, obj Serializable) (err error)

EncodeSend encodes a serializable object via the Iterum defaults:

unsigned 32bit int msg length, followed by the encoded object

If the message size exceeds 2^16 it is send in chunks of 2^16 bytes Then it sends it on the target connection

func ReadMessage

func ReadMessage(conn net.Conn) (encMsg []byte, err error)

ReadMessage reads one message worth of data from the passed connection. it leaves the data serialized, but it is guaranteed to be of the right length

Types

type ConnectionError

type ConnectionError struct {
	Err error
}

ConnectionError is raised when something with net.Conn fails (such as reading or writing)

func ErrConnection

func ErrConnection(err error) *ConnectionError

ErrConnection is used to raise a ConnectionError embedding another error

func (ConnectionError) Error

func (err ConnectionError) Error() string

func (*ConnectionError) Unwrap

func (err *ConnectionError) Unwrap() error

type Serializable

type Serializable interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) error
}

Serializable is an interface describing structures that can be encoded and decoded

type SerializationError

type SerializationError struct {
	Err error
}

SerializationError is raised when serialize or deserialize fails

func ErrSerialization

func ErrSerialization(err error) *SerializationError

ErrSerialization is used to raise a SerializationError embedding another error

func (*SerializationError) Error

func (err *SerializationError) Error() string

func (*SerializationError) Unwrap

func (err *SerializationError) Unwrap() error

Jump to

Keyboard shortcuts

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