// NewEncodable creates an object that will be encoded with the provided codec on demand.
// Provided as a convenience for test cases dealing with internal objects.
195688
func NewEncodable(e Encoder, obj Object, versions ...schema.GroupVersion) Object {
	if _, ok := obj.(*Unknown); ok {
		return obj
	}
	return encodable{e, obj, versions}
}
64924
func NewEncoder(w io.Writer) *Encoder {
	bw, ok := w.(writer)
	if !ok {
		bw = newByteWriter(w)
	}
	return &Encoder{
		w:   bw,
		buf: make([]byte, 9),
	}
}
77094
func NewEncoder(r io.Writer) Encoder {
	enc := gob.NewEncoder(r)
	return func(r *Result) error { return enc.Encode(r) }
}
382321
func NewJSONCodec(conn io.ReadWriteCloser) rpc2.Codec {
	return &jsonCodec{
		dec:     json.NewDecoder(conn),
		enc:     json.NewEncoder(conn),
		c:       conn,
		pending: make(map[uint64]*json.RawMessage),
	}
}
1075902
func NewEncoder(w io.Writer) *Encoder {
	enc := Encoder{syms: make(map[string]int, 0), tags: make(map[string]*tagDef, 0), nextTag: FirstUserTag}
	enc.out = w
	enc.bytebuf = make([]byte, 32)
	enc.writeHeader()
	return &enc
}
125091
func NewEncoder(w io.Writer, h Handle) *Encoder {
	e := newEncoder(h)
	e.Reset(w)
	return e
}
1367906
func NewDecoder(enc *Encoding, r io.Reader) io.Reader {
	return &decoder{enc: enc, r: r}
}
1309017
func NewEncoder(opts ...func(*Encoder)) *Encoder {
	e := &Encoder{
		MarshalOptions: MarshalOptions{
			SupportJSONTags: true,
		},
		NullEmptyString: true,
	}
	for _, o := range opts {
		o(e)
	}

	return e
}
857238
func (j *JSONPb) NewDecoder(r io.Reader) Decoder {
	d := json.NewDecoder(r)
	return DecoderWrapper{Decoder: d}
}
1080752
func NewEncoder(w io.Writer) *Encoder {
	return &Encoder{w: w, escapeHTML: true}
}
606145
func NewEncoder(w io.Writer) *Encoder {
	return &Encoder{
		enc: codec.NewEncoder(w, new(codec.CborHandle)),
	}
}
978005
func NewEncoder(w io.Writer) *Encoder {
	if w, ok := w.(FlushWriter); ok {
		return &Encoder{w}
	}

	return &Encoder{noopFlusher{w}}
}
1250617
func NewDecoder(s encoding.Source) encoding.Decoder {
	r := s()
	dec := framing.NewDecoder(r, json.Unmarshal)
	return encoding.DecoderFunc(func(u encoding.Unmarshaler) error { return dec.Decode(u) })
}
962452
func (e *encoder) Encode(obj runtime.Object) error {
	if err := e.encoder.Encode(obj, e.buf); err != nil {
		return err
	}
	_, err := e.writer.Write(e.buf.Bytes())
	e.buf.Reset()
	return err
}
195326
func (c *codecWrapper) Encode(obj Object) ([]byte, error) {
	return c.EncodeToVersion(obj, c.version.String())
}
624438
func NewEncoder(source string) (*Encoder, error) {

	if len(source) != 58 {
		return nil, errors.New("base58: encoding source is not 58-bytes long")
	}

	enc := new(Encoder)

	for i := range enc.decodeMap {
		enc.decodeMap[i] = -1
	}

	for i := range source {
		enc.encode[i] = source[i]
		enc.decodeMap[enc.encode[i]] = i
	}

	return enc, nil
}
1079281
func NewEncoder() *Encoder {
	return &Encoder{cache: newCache(), regenc: make(map[reflect.Type]encoderFunc)}
}