func (c *Codec) String() string {
	if c == nil {
		return ""
	}
	return c.Name
}
String implements the fmt.Stringer interface.
package encoding
import (
	"encoding/json"
	"io"
	pb "github.com/gogo/protobuf/proto"
	"github.com/mesos/mesos-go/api/v1/lib/encoding/framing"
)
type MediaType string
func (m MediaType) ContentType() string { return string(m) }
type (
	Source func() framing.Reader
	Sink   func() framing.Writer
	Codec struct {
		Name       string
		Type       MediaType
		NewEncoder func(Sink) Encoder
		NewDecoder func(Source) Decoder
	}
	SourceFactory interface {
		NewSource(r io.Reader) Source
	}
	SourceFactoryFunc func(r io.Reader) Source
	SinkFactory interface {
		NewSink(w io.Writer) Sink
	}
	SinkFactoryFunc func(w io.Writer) Sink
)
func (f SourceFactoryFunc) NewSource(r io.Reader) Source { return f(r) }
func (f SinkFactoryFunc) NewSink(w io.Writer) Sink { return f(w) }
var (
	_ = SourceFactory(SourceFactoryFunc(nil))
	_ = SinkFactory(SinkFactoryFunc(nil))
)
func SourceReader(r io.Reader) Source {
	ch := make(chan framing.ReaderFunc, 1)
	ch <- framing.ReadAll(r)
	return func() framing.Reader {
		select {
		case f := <-ch:
			return f
		default:
			return framing.ReaderFunc(framing.EOFReaderFunc)
		}
	}
}
func SinkWriter(w io.Writer) Sink { return func() framing.Writer { return framing.WriterFor(w) } }