Documentation
¶
Index ¶
- Constants
- Variables
- type FrameReader
- func (r *FrameReader) Read() (data []byte, err error)
- func (r *FrameReader) ReadCallback(cb func([]byte)) (err error)
- func (r *FrameReader) ReadCallbackMax(cb func([]byte), maxSize int) (err error)
- func (r *FrameReader) ReadMax(maxSize int) (data []byte, err error)
- func (r *FrameReader) ReadToBuffer(w io.Writer) (err error)
- func (r *FrameReader) ReadToBufferMax(w io.Writer, maxSize int) (err error)
- type FrameWriter
Constants ¶
const BLOCK_SIZE = 127
Variables ¶
var BufioPool *bufiopool.Pool = bufiopool.New(0, 0)
var ErrFrameTooLarge = errors.New("frame too large")
Frame Size Exceeds MaxSize.
var ErrInvalidBlockSize = errors.New("invalid block size")
BlockSize is bigger than the maximum BLOCK_SIZE.
var ErrSizeMismatch = errors.New("size mismatch")
Sum of all block sizes is not equal to TotalSize.
Functions ¶
This section is empty.
Types ¶
type FrameReader ¶
ReadFrame read frame from io.Reader
r: io.Reader should be buffered
func NewFrameReader ¶
func NewFrameReader(r io.Reader) FrameReader
Create a new FrameReader
r: io.Reader should be buffered
func (*FrameReader) Read ¶
func (r *FrameReader) Read() (data []byte, err error)
Read one frame from the reader and return it as a byte array. (allocates memory)
func (*FrameReader) ReadCallback ¶
func (r *FrameReader) ReadCallback(cb func([]byte)) (err error)
Read one frame from the reader and call the callback function.
Returned byte slice is not valid after the callback function returns. (due to reusing the buffer)
func (*FrameReader) ReadCallbackMax ¶ added in v1.2.0
func (r *FrameReader) ReadCallbackMax(cb func([]byte), maxSize int) (err error)
Read one frame from the reader and call the callback function.
Returned byte slice is not valid after the callback function returns. (due to reusing the buffer)
If the frame is larger than maxSize, ErrFrameTooLarge is returned.
func (*FrameReader) ReadMax ¶ added in v1.2.0
func (r *FrameReader) ReadMax(maxSize int) (data []byte, err error)
Read one frame from the reader and return it as a byte array. (allocates memory)
If the frame is larger than maxSize, ErrFrameTooLarge is returned.
func (*FrameReader) ReadToBuffer ¶
func (r *FrameReader) ReadToBuffer(w io.Writer) (err error)
Read one frame from the reader and write it to the buffer.
func (*FrameReader) ReadToBufferMax ¶ added in v1.2.0
func (r *FrameReader) ReadToBufferMax(w io.Writer, maxSize int) (err error)
Read one frame from the reader and write it to the writer.
If the frame is larger than maxSize, ErrFrameTooLarge is returned.
type FrameWriter ¶
FrameWriter write frame to io.Writer
w: io.Writer should be buffered
func NewFrameWriter ¶
func NewFrameWriter(w io.Writer) FrameWriter
Create a new FrameWriter
w: io.Writer should be buffered
func (*FrameWriter) Write ¶
func (w *FrameWriter) Write(b []byte) (err error)
Write one frame to the writer.
"N" is set to 1 if it is the last block of that frame If there are additional blocks after that, N is set to 0