protocol

package
v0.0.0-...-b6fdf8c Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InstructionMaxLength is the maximum number of characters per
	// instruction.
	InstructionMaxLength = 8192
	// InstructionMaxDigits is the maximum number of digits to allow per
	// length prefix.
	InstructionMaxDigits = 5
	// InstructionMaxElements is the maximum number of elements per
	// instruction, including the opcode.
	InstructionMaxElements = 128
)
View Source
const MaxInstructionLength = 8192

MaxInstructionLength is the maximum number of characters per instruction.

Variables

View Source
var (
	ErrInstructionMissDot   = errors.New("instruction without dot")
	ErrInstructionMissComma = errors.New("instruction without comma")
	ErrInstructionMissSemi  = errors.New("instruction withou semi")
	ErrInstructionBadDigit  = errors.New("instruction with bad digit")
	ErrInstructionBadRune   = errors.New("instruction with bad rune")
)

Errors while parsing instruction

Functions

This section is empty.

Types

type IO

type IO struct {
	// contains filtered or unexported fields
}

IO is a fd wrap that implements io.Reader and io.Writer

func NewIO

func NewIO(fd int) *IO

NewIO creates an IO

func (IO) Close

func (i IO) Close() error

Close closes the IO

func (IO) Read

func (i IO) Read(buf []byte) (n int, err error)

Read implements io.Reader

func (IO) Write

func (i IO) Write(buf []byte) (n int, err error)

Write implements io.Writer

type Instruction

type Instruction struct {
	// contains filtered or unexported fields
}

Instruction is a guacamole instruction

func NewInstruction

func NewInstruction(elements []string) *Instruction

NewInstruction creates a instruction with given elements

func ParseInstruction

func ParseInstruction(raw []byte) (ins *Instruction, err error)

ParseInstruction parses an instruction: 1.a,2.bc,3.def,10.abcdefghij;

func (Instruction) Args

func (i Instruction) Args() []string

Args returns the arguments of an instruction

func (Instruction) Expect

func (i Instruction) Expect(op string) bool

Expect op code

func (Instruction) Opcode

func (i Instruction) Opcode() string

Opcode returns the opcode of an instruction

func (Instruction) String

func (i Instruction) String() string

type InstructionIO

type InstructionIO struct {
	// contains filtered or unexported fields
}

InstructionIO implements io.Reader and io.Writer

func NewInstructionIO

func NewInstructionIO(fd int) *InstructionIO

NewInstructionIO ...

func (*InstructionIO) Close

func (io *InstructionIO) Close() error

Close closes the InstructionIO

func (*InstructionIO) Read

func (io *InstructionIO) Read() (*Instruction, error)

Read reads and parses the instruction from io input

func (*InstructionIO) ReadRaw

func (io *InstructionIO) ReadRaw() ([]byte, error)

ReadRaw reads raw data from io input

func (*InstructionIO) Write

func (io *InstructionIO) Write(ins *Instruction) (int, error)

Write writes and decodes an instruction to io output

func (*InstructionIO) WriteRaw

func (io *InstructionIO) WriteRaw(buf []byte) (n int, err error)

WriteRaw writes raw buffer into io output

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser parses an occamy instruction

func NewParser

func NewParser() Parser

NewParser creates an occamy protocol parser.

func (Parser) Parse

func (p Parser) Parse(raw []byte, ins *Instruction) (err error)

Parse parses raw inputs into a occamy instruction

type ParserState

type ParserState int

ParserState is the parsing state of a parser

const (
	ParserStateLength ParserState = iota
	ParserStateContent
	ParserStateComplete
	ParserStateError
)

All possible states of the instruction parser.

Jump to

Keyboard shortcuts

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