datapacker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 1 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPacker = ObjpackPacker{}

DefaultPacker 是默认的 packer, 即 ObjpackPacker{}

Functions

This section is empty.

Types

type ObjpackPacker

type ObjpackPacker struct{}

ObjpackPacker 是通过包装 "github.com/touee/nyn/objpack" 包中的功能实现的 Packer

func (ObjpackPacker) Formats

func (packer ObjpackPacker) Formats() (packFormat string, signatureFormat string)

Formats 返回 "objpack", "objpack-signature"

func (ObjpackPacker) Pack

func (packer ObjpackPacker) Pack(task interface{}) (packedData []byte, err error)

Pack 使用 objpack 提供的 Pack 函数打包任务

func (ObjpackPacker) Signature

func (packer ObjpackPacker) Signature(task interface{}) (signature string, err error)

Signature 使用 objpack 提供的 Signature 生成任务类型的签名

func (ObjpackPacker) Unpack

func (packer ObjpackPacker) Unpack(data []byte, task interface{}) (err error)

Unpack 使用 objpack 提供的 Unpack 函数取出被打包的任务

type Packer

type Packer interface {
	// Formats 用于标明任务被打包的成的格式, 以及对类型生成签名的格式
	Formats() (packFormat string, signatureFormat string)

	// Pack 用于打包任务
	Pack(task interface{}) (packedData []byte, err error)
	// Unpack 用于从打包的数据取出任务
	Unpack(data []byte, task interface{}) (err error)
	// Signature 用于声明任务类型的签名, 以防错误使用
	Signature(task interface{}) (signature string, err error)
}

Packer 是用于 pack/unpack 任务的接口

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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