Documentation
¶
Index ¶
- Constants
- Variables
- func BlockPayload(blockLen int64) int64
- func ConstZeroCrc(size int) uint32
- func DecodeSize(totalSize int64, blockLen int64) int64
- func DecodeSizeWithDefualtBlock(size int64) int64
- func EncodeSize(size int64, blockLen int64) int64
- func EncodeSizeWithDefualtBlock(size int64) int64
- func IsZeroBuffer(buffer []byte) bool
- func NewBlockReader(r io.Reader, limit int64, block []byte) *blockReader
- func NewDecoderReader(in io.Reader) io.Readerdeprecated
- func NewEncoderReader(r io.Reader) io.Readerdeprecated
- func NewLimitEncoderReader(r io.Reader, limitSize int64) (enc *limitEncoderReader)
- func NewPartialDecoder(rc io.ReadCloser, actualSize, stableSize int64) io.ReadCloser
- func NewPartialEncoder(rc io.ReadCloser, actualSize, stableSize int64) io.ReadCloser
- func NewSizedAppend(rc io.ReadCloser, actualSize, stableSize, blockSize int64, section bool, ...) (io.ReadCloser, error)
- func NewSizedBlockDecoder(rc io.ReadCloser, actualSize, blockSize int64) io.ReadCloser
- func NewSizedBlockEncoder(rc io.ReadCloser, actualSize, blockSize int64) io.ReadCloser
- func NewSizedCoder(rc io.ReadCloser, actualSize, stableSize, blockSize int64, mode uint8, ...) io.ReadCloser
- func NewSizedDecoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
- func NewSizedEncoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
- func NewSizedFixer(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
- func NewSizedRangeBlockDecoder(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
- func NewSizedRangeDecoder(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
- func NewSizedSectionDecoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
- func PartialDecodeSize(totalSize, tail, stableSize int64) int64
- func PartialDecodeSizeWith(totalSize, tail, stableSize, blockLen int64) int64
- func PartialEncodeSize(actualSize, stableSize int64) (int64, int64)
- func PartialEncodeSizeWith(actualSize, stableSize, blockLen int64) (int64, int64)
- func SetBlockSize(blockSize int64)
- type Decoder
- type Encoder
- type ReaderError
- type RequestBody
- type WriterError
Constants ¶
const ( // write crc after payload ModeEncode uint8 = 1 // encode mode ModeAppend uint8 = 2 // append, append buffer to stable, just fix first block ModeCheck uint8 = 3 // check, return buffer with head, crc and tail ModeDecode uint8 = 4 // decode, return data buffer ModeLoad uint8 = 5 // load, return buffer with head, should with section ModeFix uint8 = 6 // fix, return buffer with fixed first and last block crc // write crc before payload ModeBlockEncode uint8 = 11 // encode mode, crc at head of block ModeBlockDecode uint8 = 12 // decode, return buffer with crc size and head )
Variables ¶
var ( ErrInvalidBlock = errors.New("crc32block: invalid block buffer") ErrMismatchedCrc = errors.New("crc32block: mismatched checksum") ErrReadOnClosed = errors.New("crc32block: read on closed") )
var ErrFrameContinue = transport.ErrFrameContinue
Functions ¶
func BlockPayload ¶
func ConstZeroCrc ¶
func DecodeSize ¶
func EncodeSize ¶
func IsZeroBuffer ¶
func NewDecoderReader
deprecated
func NewEncoderReader
deprecated
func NewLimitEncoderReader ¶
func NewPartialDecoder ¶
func NewPartialDecoder(rc io.ReadCloser, actualSize, stableSize int64) io.ReadCloser
NewPartialDecoder returns partial crc32 decoder.
func NewPartialEncoder ¶
func NewPartialEncoder(rc io.ReadCloser, actualSize, stableSize int64) io.ReadCloser
NewPartialEncoder returns partial crc32 encoder, added the padding buffer, actual size is next content size, stable size was written content size.
func NewSizedAppend ¶
func NewSizedAppend(rc io.ReadCloser, actualSize, stableSize, blockSize int64, section bool, lastpad, lastcrc []byte, ) (io.ReadCloser, error)
NewSizedAppend returns sized alignment crc32 append encoder.
func NewSizedBlockDecoder ¶
func NewSizedBlockDecoder(rc io.ReadCloser, actualSize, blockSize int64) io.ReadCloser
NewSizedBlockDecoder return block sized decoder.
func NewSizedBlockEncoder ¶
func NewSizedBlockEncoder(rc io.ReadCloser, actualSize, blockSize int64) io.ReadCloser
NewSizedBlockEncoder return block sized encoder.
func NewSizedCoder ¶
func NewSizedCoder(rc io.ReadCloser, actualSize, stableSize, blockSize int64, mode uint8, section bool) io.ReadCloser
NewSizedCoder returns sized alignment crc32 en-decoder.
func NewSizedDecoder ¶
func NewSizedDecoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
NewSizedDecoder returns sized crc32 decoder.
func NewSizedEncoder ¶
func NewSizedEncoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
NewSizedEncoder returns sized crc32 encoder.
func NewSizedFixer ¶
func NewSizedFixer(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
NewSizedFixer returns fixed-range crc32 data, [from, to). The from should be in the first block of reader. Only fix the first and last block if needed, do not check other blocks. Returns head and tail are aligned.
func NewSizedRangeBlockDecoder ¶
func NewSizedRangeBlockDecoder(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
NewSizedRangeBlockDecoder returns ranged crc32 block decoder, [from, to). The from should be in the first block of reader.
func NewSizedRangeDecoder ¶
func NewSizedRangeDecoder(rc io.ReadCloser, actualSize, from, to, blockSize int64) (int64, int64, io.ReadCloser)
NewSizedRangeDecoder returns ranged crc32 decoder, [from, to). The from should be in the first block of reader.
func NewSizedSectionDecoder ¶
func NewSizedSectionDecoder(rc io.ReadCloser, actualSize int64) io.ReadCloser
NewSizedSectionDecoder returns section crc32 decoder.
func PartialDecodeSize ¶
func PartialDecodeSizeWith ¶
func PartialEncodeSize ¶
func PartialEncodeSizeWith ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoderWithBlock ¶
type ReaderError ¶
type ReaderError struct {
// contains filtered or unexported fields
}
type RequestBody ¶
type RequestBody interface {
io.ReadCloser
// CodeSize returns encoded whole body size for encoding,
// or origin body size for decoding.
CodeSize(int64) int64
}
RequestBody is implemented http request's body. always io.ReadCloser.
For client requests, The HTTP Client's Transport is responsible for calling the Close method. Necessarily call the Close method if the body's life-cycle control by yourself.
For server requests, the Server will close the request body. The ServeHTTP Handler does not need to.
The Body must allow Read to be called concurrently with Close. In particular, calling Close should unblock a Read waiting for input.
func NewBodyDecoder ¶
func NewBodyDecoder(rc io.ReadCloser) RequestBody
NewBodyDecoder returns decoder with crc32.
If rc == nil, the decoder is called just with CodeSize, you need not to Close it at all.
func NewBodyEncoder ¶
func NewBodyEncoder(rc io.ReadCloser) RequestBody
NewBodyEncoder returns encoder with crc32.
If rc == nil, the encoder is called just with CodeSize, you need not to Close it at all.
type WriterError ¶
type WriterError struct {
// contains filtered or unexported fields
}