Documentation ¶
Index ¶
- Variables
- type ByteArrayDecoder
- type ByteArrayEncoder
- type ByteArrayEncoding
- type ByteArrayEncrypter
- type ByteEncoding
- func NewBase32Encoding(encoding *base32.Encoding) ByteEncoding
- func NewBase64Encoding(encoding *base64.Encoding) ByteEncoding
- func NewFlateEncoding(level int, dict []byte) ByteEncoding
- func NewGzipEncoding(level int) ByteEncoding
- func NewHexEncoding() ByteEncoding
- func NewNoopEncoding() ByteEncoding
- func NewReadWriteEncoding(builder ReaderWriterBuilder) ByteEncoding
- func NewZlibEncoding(level int, dict []byte) ByteEncoding
- type ByteStreamDecoder
- type ByteStreamEncoder
- type ByteStreamEncoding
- type Encoding
- type ReaderWriterBuilder
- type StreamDecoder
- type StreamEncoder
- type StreamEncoding
- type ValueDecoder
- type ValueEncoder
- type ValueEncoding
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Base32StdEncoding = NewBase32Encoding(base32.StdEncoding) Base32URLEncoding = NewBase32Encoding(base32.HexEncoding) )
View Source
var ( Base64StdEncoding = NewBase64Encoding(base64.StdEncoding) Base64URLEncoding = NewBase64Encoding(base64.URLEncoding) )
View Source
var (
ErrNotAPointer = errors.New("argument must be a pointer")
)
View Source
var FlateEncoding = NewFlateEncoding(flate.DefaultCompression, nil)
View Source
var GobEncoding = NewGobEncoding()
View Source
var GzipEncoding = NewGzipEncoding(gzip.DefaultCompression)
View Source
var HexEncoding = NewHexEncoding()
View Source
var JSONEncoding = NewJSONEncoding()
View Source
var LiteralEncoding = NewLiteralEncoding(nil)
View Source
var NoopEncoding = NewNoopEncoding()
View Source
var ZlibEncoding = NewZlibEncoding(zlib.DefaultCompression, nil)
Functions ¶
This section is empty.
Types ¶
type ByteArrayDecoder ¶
type ByteArrayEncoder ¶
type ByteArrayEncoding ¶
type ByteArrayEncoding interface { ByteArrayEncoder ByteArrayDecoder }
func NewByteArrayEncrypterEncoding ¶
func NewByteArrayEncrypterEncoding(encrypter ByteArrayEncrypter) ByteArrayEncoding
func NewChainByteArrayEncoding ¶
func NewChainByteArrayEncoding(encodings ...ByteArrayEncoding) ByteArrayEncoding
type ByteArrayEncrypter ¶
type ByteArrayEncrypter interface { Encrypt([]byte) ([]byte, error) Decrypt([]byte) ([]byte, error) }
ByteArrayEncrypter is provided as a common interface for encryption operations
type ByteEncoding ¶
type ByteEncoding interface { ByteArrayEncoding ByteStreamEncoding }
func NewBase32Encoding ¶
func NewBase32Encoding(encoding *base32.Encoding) ByteEncoding
func NewBase64Encoding ¶
func NewBase64Encoding(encoding *base64.Encoding) ByteEncoding
func NewFlateEncoding ¶
func NewFlateEncoding(level int, dict []byte) ByteEncoding
func NewGzipEncoding ¶
func NewGzipEncoding(level int) ByteEncoding
func NewHexEncoding ¶
func NewHexEncoding() ByteEncoding
func NewNoopEncoding ¶
func NewNoopEncoding() ByteEncoding
func NewReadWriteEncoding ¶
func NewReadWriteEncoding(builder ReaderWriterBuilder) ByteEncoding
func NewZlibEncoding ¶
func NewZlibEncoding(level int, dict []byte) ByteEncoding
type ByteStreamDecoder ¶
type ByteStreamDecoder interface {
StreamDecode(io.Reader) (io.ReadCloser, error)
}
type ByteStreamEncoder ¶
type ByteStreamEncoder interface {
StreamEncode(io.Writer) (io.WriteCloser, error)
}
type ByteStreamEncoding ¶
type ByteStreamEncoding interface { ByteStreamEncoder ByteStreamDecoder }
func NewChainByteStreamEncoding ¶
func NewChainByteStreamEncoding(encodings ...ByteStreamEncoding) ByteStreamEncoding
type Encoding ¶
type Encoding interface { ValueEncoding StreamEncoding }
func NewJSONEncoding ¶
func NewJSONEncoding() Encoding
func NewStreamEncoding ¶
func NewStreamEncoding(e ValueEncoding) Encoding
NewStreamEncoding creates an Encoding respecting the StreamEncoding interface from a ValueEncoding
func NewValueEncoding ¶
func NewValueEncoding(e StreamEncoding) Encoding
NewValueEncoding creates an Encoding respecting the ValueEncoding interface from a StreamEncoding
type ReaderWriterBuilder ¶
type ReaderWriterBuilder interface { NewReader(io.Reader) (io.ReadCloser, error) NewWriter(io.Writer) (io.WriteCloser, error) }
type StreamDecoder ¶
type StreamEncoder ¶
type StreamEncoding ¶
type StreamEncoding interface { StreamEncoder StreamDecoder }
func NewGobEncoding ¶
func NewGobEncoding() StreamEncoding
func NewWrappedStreamEncoding ¶
func NewWrappedStreamEncoding(encoding StreamEncoding, byteEncodings ...ByteStreamEncoding) StreamEncoding
type ValueDecoder ¶
type ValueEncoder ¶
type ValueEncoding ¶
type ValueEncoding interface { ValueEncoder ValueDecoder }
Example ¶
e := encoding.NewWrappedValueEncoding(encoding.JSONEncoding, encoding.GzipEncoding, encoding.Base64StdEncoding) enc, _ := e.Encode(123) var num int _ = e.Decode(enc, &num) fmt.Printf("literal number, encoded: %s, decoded: %d\n", enc, num) enc, _ = e.Encode("123") var s string _ = e.Decode(enc, &s) fmt.Printf("literal string, encoded: %s, decoded: %s\n", enc, s) enc, _ = e.Encode(map[string]string{"foo": "bar"}) var m map[string]string _ = e.Decode(enc, &m) fmt.Printf("json map, encoded: %s, decoded: %+v\n", enc, m)
Output: literal number, encoded: H4sIAAAAAAAA/zI0MgYEAAD//9JjSIgDAAAA, decoded: 123 literal string, encoded: H4sIAAAAAAAA/1IyNDJWAgQAAP//lwFQMwUAAAA=, decoded: 123 json map, encoded: H4sIAAAAAAAA/6pWSsvPV7JSSkosUqoFBAAA///v9Sv+DQAAAA==, decoded: map[foo:bar]
func NewLiteralEncoding ¶
func NewLiteralEncoding(fallback ValueEncoding) ValueEncoding
NewLiteralEncoding is an encoding that will try its best to store the data as is, but fallback on another encoder if not possible.
func NewWrappedValueEncoding ¶
func NewWrappedValueEncoding(encoding ValueEncoding, byteEncodings ...ByteArrayEncoding) ValueEncoding
Source Files ¶
- base32_encoding.go
- base64_encoding.go
- buffered.go
- byte_encoding.go
- chain_byte_encoding.go
- closer.go
- encoding.go
- encrypter_encoding.go
- flate_encoding.go
- gob_encoding.go
- gzip_encoding.go
- hex_encoding.go
- json_encoding.go
- literal_marshalling.go
- noop_encoding.go
- pointer.go
- read_write_encoding.go
- translators.go
- wrapped_encoding.go
- zlib_encoding.go
Click to show internal directories.
Click to hide internal directories.