pktline

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderLength = 4
	MaxLength    = 65524
)

Variables

View Source
var (
	ErrUnderflow     = errors.New("unexpected string length (underflow)")
	ErrInvalidHeader = errors.New("invalid header")
	ErrInvalidLen    = errors.New("invalid length")
)
View Source
var (
	ErrOverflow = errors.New("unexpected string length (overflow)")
)

Functions

func Encode

func Encode(line []byte) (string, error)

Encode encodes a byte slice to pkt-line format

func EncodeFromString

func EncodeFromString(line string) (string, error)

EncodeFromString encodes a string to pkt-line format

Types

type Decoder

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

Decoder implements a pkt-line format decoder

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a new Decoder

func (*Decoder) ReadAll

func (d *Decoder) ReadAll() ([]string, error)

ReadAll read and returns all the lines

func (*Decoder) ReadBlock

func (d *Decoder) ReadBlock() ([]string, error)

ReadBlock reads and return multiple pkt-line lines, it stops at the end of the reader or if a flush-pkt is reached

func (*Decoder) ReadLine

func (d *Decoder) ReadLine() (string, error)

ReadLine reads and return one pkt-line line from the reader

type Encoder

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

Encoder implements a pkt-line format encoder

func NewEncoder

func NewEncoder() *Encoder

NewEncoder returns a new Encoder

func (*Encoder) AddFlush

func (e *Encoder) AddFlush()

AddFlush adds a flush-pkt to the encoder

func (*Encoder) AddLine

func (e *Encoder) AddLine(line string) error

AddLine encode and adds a line to the encoder

func (*Encoder) Reader

func (e *Encoder) Reader() *strings.Reader

Reader returns a string.Reader over the encoder

Jump to

Keyboard shortcuts

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