encoding

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec struct {
	Name       string
	Type       MediaType
	NewEncoder func(Sink) Encoder
	NewDecoder func(Source) Decoder
}

A Codec composes encoding and decoding of a serialization format.

func (*Codec) String

func (c *Codec) String() string

String implements the fmt.Stringer interface.

type Decoder

type Decoder interface {
	Decode(Unmarshaler) error
}

A Decoder decodes a given Unmarshaler or returns an error in case of failure.

type DecoderFunc

type DecoderFunc func(Unmarshaler) error

DecoderFunc is the functional adapter for Decoder

func (DecoderFunc) Decode

func (f DecoderFunc) Decode(u Unmarshaler) error

Decode implements the Decoder interface

type Encoder

type Encoder interface {
	Encode(Marshaler) error
}

An Encoder encodes a given Marshaler or returns an error in case of failure.

type EncoderFunc

type EncoderFunc func(Marshaler) error

EncoderFunc is the functional adapter for Encoder

func (EncoderFunc) Encode

func (f EncoderFunc) Encode(m Marshaler) error

Encode implements the Encoder interface

type Marshaler

type Marshaler interface {
	pb.Marshaler
	json.Marshaler
}

Marshaler composes the supported marshaling formats.

type MediaType

type MediaType string

func (MediaType) ContentType

func (m MediaType) ContentType() string

ContentType returns the HTTP Content-Type associated with the MediaType

type Sink

type Sink func() framing.Writer

func SinkWriter

func SinkWriter(w io.Writer) Sink

SinkWriter returns a Sink that sends a frame to an io.Writer with no decoration.

type SinkFactory

type SinkFactory interface {
	NewSink(w io.Writer) Sink
}

type SinkFactoryFunc

type SinkFactoryFunc func(w io.Writer) Sink

func (SinkFactoryFunc) NewSink

func (f SinkFactoryFunc) NewSink(w io.Writer) Sink

type Source

type Source func() framing.Reader

func SourceReader

func SourceReader(r io.Reader) Source

SourceReader returns a Source that buffers all input from the given io.Reader and returns the contents in a single frame.

type SourceFactory

type SourceFactory interface {
	NewSource(r io.Reader) Source
}

type SourceFactoryFunc

type SourceFactoryFunc func(r io.Reader) Source

func (SourceFactoryFunc) NewSource

func (f SourceFactoryFunc) NewSource(r io.Reader) Source

type Unmarshaler

type Unmarshaler interface {
	pb.Unmarshaler
	json.Unmarshaler
}

Unmarshaler composes the supporter unmarshaling formats.

Directories

Path Synopsis
Package proto implements protobuf utilities such as functional options to construct complex structs and encoders and decoders composable with io.ReadWriters.
Package proto implements protobuf utilities such as functional options to construct complex structs and encoders and decoders composable with io.ReadWriters.

Jump to

Keyboard shortcuts

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