protocol

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReqIDHello uint = iota
)
View Source
const (
	RspIDEmpty uint = iota
)
View Source
const StreamOffSize = vamp.Size32

Variables

View Source
var (
	ReqVersion []byte
	RspVersion []byte
)
View Source
var VampRequest = vamp.NewUnion(vamp.Size8,
	vamp.MustNamed("hello", vamp.MustUseStruct(HelloRequest{})),
).SetAltReader(func(alt uint, into any) (any, error) {
	i := into.(*any)
	switch alt {
	case ReqIDHello:
		*i = new(HelloRequest)
		return *i, nil
	}
	return nil, fmt.Errorf("unknown request id %d", alt)
})
View Source
var VampResponse = vamp.NewUnion(vamp.Size8,
	vamp.MustNamed("empty", vamp.Uint16),
).SetAltReader(func(alt uint, into any) (any, error) {
	i := into.(*any)
	switch alt {
	case RspIDEmpty:
		*i = new(ResponseCode)
		return *i, nil
	}
	return nil, fmt.Errorf("unknown response id %d", alt)
})

Functions

This section is empty.

Types

type HelloRequest

type HelloRequest struct {
	RequestHeader
	ReqProto []byte `vamp:"size=8"`
	RspProto []byte `vamp:"size=8"`
}

func (*HelloRequest) VampUnionAlt

func (rq *HelloRequest) VampUnionAlt() (uint, any)

type RequestHeader

type RequestHeader struct {
	Token   string `vamp:"size=8"`
	MsgTime time.Time
}

type ResponseCode

type ResponseCode uint16
const (
	RspOK ResponseCode = iota
	RspProtoMismatch
)

func (ResponseCode) String

func (i ResponseCode) String() string

func (*ResponseCode) VampFromUint16

func (rc *ResponseCode) VampFromUint16(i uint16) error

func (ResponseCode) VampUnionAlt

func (rp ResponseCode) VampUnionAlt() (uint, any)

Jump to

Keyboard shortcuts

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