summaryrefslogtreecommitdiff
path: root/pkg/payload/payload.go
blob: bebe8df1e950ba00f8d199b9cee7b63d0394f76e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package payload

import "unsafe"

// Payload carries binary header and body to stack and
// back to the server.
type Payload struct {
	// Context represent payload context, might be omitted.
	Context []byte

	// body contains binary payload to be processed by WorkerProcess.
	Body []byte
}

// String returns payload body as string
func (p *Payload) String() string {
	return toString(p.Body)
}

// unsafe, but lightning fast []byte to string conversion
func toString(data []byte) string {
	return *(*string)(unsafe.Pointer(&data))
}