go_wireproto/consts.go

105 lines
3.0 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 is the [IndentChars] to use if not specified.
2024-07-09 23:40:20 -04:00
IndentDefault string = "\t"
// SeperatorDefault is the [SeperatorChars] to use if not specified.
2024-07-09 23:40:20 -04:00
SeparatorDefault string = " "
maxByteLine int = 12 // (Split a hex string in a Model if a value is more than this number of bytes.)
2024-07-09 23:40:20 -04:00
)
// Default indent levels.
2024-07-09 23:40:20 -04:00
const (
indentR uint = iota
indentRG
indentRec
indentKvp
)
const indentOrigRec uint = 2
const (
// ProtoVersion specifies the protocol version for the specification of a [Message].
2024-07-09 23:40:20 -04:00
ProtoVersion uint32 = 1
)
const (
// PackedNumSize is the size (length of bytes) of a packed unsigned integer.
PackedNumSize int = 4 // (They're all uint32's.)
2024-07-09 23:40:20 -04:00
// CksumPackedSize is the size (length of bytes) of the checksum algorithm used.
CksumPackedSize int = 4 // CRC32 is represented by a big-endian uint32, but if a different algo is used, this will need to be changed.
2024-07-09 23:40:20 -04:00
)
// See https://square-r00t.net/ascii.html for further details on ASCII symbols.
2024-07-09 23:40:20 -04:00
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
)
// Response Status indicator bytes.
2024-07-09 23:40:20 -04:00
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 is the default size of chunking to use (in bytes) when using chunked Write* functions (i.e. non-segmented).
2024-07-09 23:40:20 -04:00
WriteChunkSize int = 1024
)