crc32block

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidBlock  = errors.New("crc32block: invalid block buffer")
	ErrMismatchedCrc = errors.New("crc32block: mismatched checksum")
	ErrReadOnClosed  = errors.New("crc32block: read on closed")
)

Functions

func DecodeSize

func DecodeSize(totalSize int64, blockLen int64) int64

func DecodeSizeWithDefualtBlock

func DecodeSizeWithDefualtBlock(size int64) int64

func EncodeSize

func EncodeSize(size int64, blockLen int64) int64

func EncodeSizeWithDefualtBlock

func EncodeSizeWithDefualtBlock(size int64) int64

func NewBlockReader

func NewBlockReader(r io.Reader, limit int64, block []byte) *blockReader

func NewDecoderReader deprecated

func NewDecoderReader(in io.Reader) io.Reader

NewDecoderReader returns io.Reader

Deprecated: no reused buffer, use NewBodyDecoder to instead.

func NewEncoderReader deprecated

func NewEncoderReader(r io.Reader) io.Reader

NewEncoderReader returns io.Reader

Deprecated: no reused buffer, use NewBodyEncoder to instead.

func NewLimitEncoderReader

func NewLimitEncoderReader(r io.Reader, limitSize int64) (enc *limitEncoderReader)

func SetBlockSize

func SetBlockSize(blockSize int64)

SetBlockSize set default block size

Types

type Decoder

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

func NewDecoder

func NewDecoder(r io.ReaderAt, off int64, size int64) (dec *Decoder, err error)

func NewDecoderWithBlock

func NewDecoderWithBlock(r io.ReaderAt, off int64, size int64, block []byte, bufferSize int64) (dec *Decoder, err error)

func (*Decoder) Reader

func (dec *Decoder) Reader(from, to int64) (r io.Reader, err error)

type Encoder

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

func NewEncoder

func NewEncoder(block []byte) (enc *Encoder, err error)

func (*Encoder) Encode

func (enc *Encoder) Encode(from io.Reader, limitSize int64, to io.Writer) (n int64, err error)

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
}

Jump to

Keyboard shortcuts

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