go_wireproto/consts.go

100 lines
2.7 KiB
Go
Raw Normal View History

2024-07-09 23:40:20 -04:00
package wireproto
import (
`encoding/binary`
)
var (
// IndentChars is used when rendering a Model; it indicates the leading indent.
IndentChars string = IndentDefault
// SeparatorChars is used when rendering a Model; it indicates the separation between the value and the comment.
SeparatorChars string = SeparatorDefault
)
const (
IndentDefault string = "\t"
SeparatorDefault string = " "
maxByteLine int = 12 // split if a value is more than this number of bytes..
)
const (
indentR uint = iota
indentRG
indentRec
indentKvp
)
const indentOrigRec uint = 2
const (
// ProtoVersion specifies the protocol version for the specification of a Message.
ProtoVersion uint32 = 1
)
const (
// PackedNumSize is the size (length of bytes) of a packed unsigned integer.
PackedNumSize int = 4 // They're all uint32's.
// CksumPackedSize is the size (length of bytes) of the checksum algorithm used.
CksumPackedSize int = 4 // CRC32 is a big-endian uint32, but if we use a different algo we need to change this.
)
// See https://square-r00t.net/ascii.html for further details.
const (
AsciiNUL uint8 = iota // 0x00
AsciiSOH // 0x01
AsciiSTX // 0x02
AsciiETX // 0x03
AsciiEOT // 0x04
AsciiENQ // 0x05
AsciiACK // 0x06
AsciiBEL // 0x07
AsciiBS // 0x08
AsciiHT // 0x09
AsciiLF // 0x0a
AsciiVT // 0x0b
AsciiFF // 0x0c
AsciiCR // 0x0d
AsciiSO // 0x0e
AsciiSI // 0x0f
AsciiDLE // 0x10
AsciiDC1 // 0x11
AsciiDC2 // 0x12
AsciiDC3 // 0x13
AsciiDC4 // 0x14
AsciiNAK // 0x15
AsciiSYN // 0x16
AsciiETB // 0x17
AsciiCAN // 0x18
AsciiEM // 0x19
AsciiSUB // 0x1a
AsciiESC // 0x1b
AsciiFS // 0x1c
AsciiGS // 0x1d
AsciiRS // 0x1e
AsciiUS // 0x1f
)
const (
RespStatusByteOK uint8 = AsciiACK
RespStatusByteErr = AsciiNAK
)
var (
byteOrder binary.ByteOrder = binary.BigEndian
)
var (
respStatusOK []byte = []byte{RespStatusByteOK}
respStatusErr []byte = []byte{RespStatusByteErr}
// hdrCKSUM *must* be *exactly* as long as hdrMSGSTART and *must not* match hdrMSGSTART.
hdrCKSUM []byte = []byte{AsciiESC}
hdrMSGSTART []byte = []byte{AsciiSOH}
hdrBODYSTART []byte = []byte{AsciiSTX}
hdrBODYEND []byte = []byte{AsciiETX}
hdrMSGEND []byte = []byte{AsciiEOT}
endSeq []byte = []byte{AsciiETX, AsciiEOT}
)
const (
WriteChunkSize int = 1024
)