payload

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0, BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSize = 65157

MaxSize defines the maximum allowed size of a marshaled Payload (in bytes). MaxPayloadSize = MaxMessageSize -

(version(1) + parentsCount(1) + parentsType(1) + maxParents(8) * 32 + issuerPK(32) +
issuanceTime(8) + seqNum(8) + nonce(8) + signature(64) = MaxMessageSize - 379 bytes = 65157
View Source
const TypeLength = marshalutil.Uint32Size

TypeLength contains the amount of bytes of a marshaled Type.

Variables

View Source
var GenericDataPayloadType = NewType(0, "GenericDataPayloadType", GenericDataPayloadUnmarshaler)

GenericDataPayloadType is the Type of a generic GenericDataPayload.

Functions

This section is empty.

Types

type GenericDataPayload

type GenericDataPayload struct {
	// contains filtered or unexported fields
}

GenericDataPayload represents a payload which just contains a blob of data.

func GenericDataPayloadFromBytes

func GenericDataPayloadFromBytes(bytes []byte) (genericDataPayload *GenericDataPayload, consumedBytes int, err error)

GenericDataPayloadFromBytes unmarshals a GenericDataPayload from a sequence of bytes.

func GenericDataPayloadFromMarshalUtil

func GenericDataPayloadFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (genericDataPayload *GenericDataPayload, err error)

GenericDataPayloadFromMarshalUtil unmarshals a GenericDataPayload using a MarshalUtil (for easier unmarshaling).

func NewGenericDataPayload

func NewGenericDataPayload(data []byte) *GenericDataPayload

NewGenericDataPayload creates new GenericDataPayload.

func (*GenericDataPayload) Blob

func (g *GenericDataPayload) Blob() []byte

Blob returns the contained data of the GenericDataPayload (without its type and size headers).

func (*GenericDataPayload) Bytes

func (g *GenericDataPayload) Bytes() []byte

Bytes returns a marshaled version of the Payload.

func (*GenericDataPayload) String

func (g *GenericDataPayload) String() string

String returns a human readable version of the Payload.

func (*GenericDataPayload) Type

func (g *GenericDataPayload) Type() Type

Type returns the Type of the Payload.

type Payload

type Payload interface {
	// Type returns the Type of the Payload.
	Type() Type

	// Bytes returns a marshaled version of the Payload.
	Bytes() []byte

	// String returns a human readable version of the Payload.
	String() string
}

Payload represents the generic interface for an object that can be embedded in Messages of the Tangle.

func FromBytes

func FromBytes(payloadBytes []byte) (payload Payload, consumedBytes int, err error)

FromBytes unmarshals a Payload from a sequence of bytes.

func FromMarshalUtil

func FromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (payload Payload, err error)

FromMarshalUtil unmarshals a Payload using a MarshalUtil (for easier unmarshaling).

func GenericDataPayloadUnmarshaler

func GenericDataPayloadUnmarshaler(data []byte) (Payload, error)

GenericDataPayloadUnmarshaler is the UnmarshalerFunc of the GenericDataPayload which is also used as a unmarshaler for unknown Types.

type Type

type Type uint32

Type represents the Type of a payload.

func NewType

func NewType(typeNumber uint32, typeName string, typeUnmarshaler UnmarshalerFunc) (payloadType Type)

NewType creates and registers a new payload Type.

func TypeFromBytes

func TypeFromBytes(typeBytes []byte) (typeResult Type, consumedBytes int, err error)

TypeFromBytes unmarshals a Type from a sequence of bytes.

func TypeFromMarshalUtil

func TypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (typeResult Type, err error)

TypeFromMarshalUtil unmarshals a Type using a MarshalUtil (for easier unmarshaling).

func (Type) Bytes

func (t Type) Bytes() (bytes []byte)

Bytes returns a marshaled version of the Type.

func (Type) String

func (t Type) String() string

String returns a human readable version of the Type for debug purposes.

type UnmarshalerFunc

type UnmarshalerFunc func(data []byte) (Payload, error)

UnmarshalerFunc defines the function signature for functions that can unmarshal Payloads.

func Unmarshaler

func Unmarshaler(payloadType Type) UnmarshalerFunc

Unmarshaler returns the UnmarshalerFunc for the given Type or the GenericDataPayloadUnmarshaler if the Type is unknown.

Jump to

Keyboard shortcuts

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