piper

package
v0.8.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAESDecode = errors.New("wrong secret or corrupted data")

Functions

func NewDebug added in v0.1.0

func NewDebug(prefix string, r io.Reader, w io.Writer) io.ReadWriter

func NopCloser added in v0.1.0

func NopCloser(w io.Writer) io.WriteCloser

Types

type AES

type AES struct {
	Key   []byte
	Guard int
}

func (*AES) Decoder

func (a *AES) Decoder(r io.Reader) (io.ReadCloser, error)

func (*AES) Encoder

func (a *AES) Encoder(w io.Writer) (io.WriteCloser, error)

type Base64

type Base64 struct {
	Encoding *base64.Encoding
}

func (*Base64) Decoder

func (e *Base64) Decoder(r io.Reader) (io.ReadCloser, error)

func (*Base64) Encoder

func (e *Base64) Encoder(w io.Writer) (io.WriteCloser, error)

type Buffer added in v0.0.5

type Buffer []byte

func (*Buffer) Consume added in v0.0.5

func (b *Buffer) Consume(dst []byte) int

Consume consumes the buffer to dst and returns the number of bytes consumed.

type Debug added in v0.1.0

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

func (*Debug) Read added in v0.1.0

func (d *Debug) Read(p []byte) (n int, err error)

func (*Debug) Write added in v0.1.0

func (d *Debug) Write(p []byte) (n int, err error)

type EncodeDecoder

type EncodeDecoder interface {
	// Encoder returns a writer that will encode data to out.
	// When the Close method is called, it should not close the underlying writer,
	// it should only flush the pending data from buffer.
	Encoder(out io.Writer) (io.WriteCloser, error)

	// Decoder returns a reader that will decode the data from in.
	Decoder(in io.Reader) (io.ReadCloser, error)
}

func Join

func Join(list ...EncodeDecoder) EncodeDecoder

func NewAES

func NewAES(key []byte, guard int) EncodeDecoder

NewAES creates a new AES encoder/decoder. The aesType must be 0, 16, 24, or 32 to select, if it's 0, no KDF will be used, the key will be used directly.

func NewBase64

func NewBase64() EncodeDecoder

func NewGzip

func NewGzip() EncodeDecoder

type EncodeDecoderFn

type EncodeDecoderFn struct {
	E func(io.Writer) (io.WriteCloser, error)
	D func(io.Reader) (io.ReadCloser, error)
}

func (*EncodeDecoderFn) Decoder

func (ed *EncodeDecoderFn) Decoder(r io.Reader) (io.ReadCloser, error)

func (*EncodeDecoderFn) Encoder

func (ed *EncodeDecoderFn) Encoder(w io.Writer) (io.WriteCloser, error)

type EndErrors added in v0.1.0

type EndErrors []byte

func (EndErrors) Error added in v0.1.0

func (e EndErrors) Error() string

type Ender added in v0.1.0

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

Ender acts like a proxy for the a io.ReadWriteCloser. The writer can send EndErrors to the reader. It will use json to marshal the error for the reader.

func NewEnder added in v0.1.0

func NewEnder(rw io.ReadWriteCloser) *Ender

func (Ender) Close added in v0.1.0

func (e Ender) Close() error

func (Ender) End added in v0.1.0

func (e Ender) End(err error) error

func (Ender) Read added in v0.1.0

func (e Ender) Read(p []byte) (n int, err error)

func (Ender) Write added in v0.1.0

func (e Ender) Write(p []byte) (n int, err error)

type Gzip

type Gzip struct {
	Level int
}

func (*Gzip) Decoder

func (g *Gzip) Decoder(r io.Reader) (io.ReadCloser, error)

func (*Gzip) Encoder

func (g *Gzip) Encoder(w io.Writer) (io.WriteCloser, error)

type ReadClose added in v0.0.5

type ReadClose struct {
	R func(p []byte) (n int, err error)
	C func() error
}

func (ReadClose) Close added in v0.0.5

func (rc ReadClose) Close() error

func (ReadClose) Read added in v0.0.5

func (rc ReadClose) Read(p []byte) (n int, err error)

type ReadEnder added in v0.1.0

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

func NewReadEnder added in v0.1.0

func NewReadEnder(r io.Reader) *ReadEnder

func (ReadEnder) Read added in v0.1.0

func (r ReadEnder) Read(p []byte) (n int, err error)

type Transformer added in v0.1.0

type Transformer struct {
	Transform func() ([]byte, error)
	// contains filtered or unexported fields
}

func NewTransformer added in v0.1.0

func NewTransformer(t func() ([]byte, error)) *Transformer

func (*Transformer) Read added in v0.1.0

func (t *Transformer) Read(p []byte) (n int, err error)

type Transparent added in v0.1.0

type Transparent struct{}

func (*Transparent) Decoder added in v0.1.0

func (t *Transparent) Decoder(r io.Reader) (io.ReadCloser, error)

func (*Transparent) Encoder added in v0.1.0

func (t *Transparent) Encoder(w io.Writer) (io.WriteCloser, error)

type WrapReadCloser added in v0.3.0

type WrapReadCloser struct {
	Reader io.Reader
	Closer io.Closer
}

func (*WrapReadCloser) Close added in v0.3.0

func (w *WrapReadCloser) Close() error

func (*WrapReadCloser) Read added in v0.3.0

func (w *WrapReadCloser) Read(p []byte) (n int, err error)

type WriteClose added in v0.0.5

type WriteClose struct {
	W func(p []byte) (n int, err error)
	C func() error
}

func (WriteClose) Close added in v0.0.5

func (wc WriteClose) Close() error

func (WriteClose) Write added in v0.0.5

func (wc WriteClose) Write(p []byte) (n int, err error)

type WriteEnder added in v0.1.0

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

func NewWriteEnder added in v0.1.0

func NewWriteEnder(w io.WriteCloser) *WriteEnder

func (WriteEnder) Close added in v0.1.0

func (w WriteEnder) Close() error

func (WriteEnder) End added in v0.1.0

func (w WriteEnder) End(e error) error

func (WriteEnder) Write added in v0.1.0

func (w WriteEnder) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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