// GobDecode implements the gob.GobDecoder interface.
558942
func (z *Dec) GobDecode(buf []byte) error {
	if len(buf) == 0 {
		return fmt.Errorf("Dec.GobDecode: no data")
	}
	b := buf[len(buf)-1]
	if b != decGobVersion {
		return fmt.Errorf("Dec.GobDecode: encoding version %d not supported", b)
	}
	l := len(buf) - scaleSize - 1
	err := z.UnscaledBig().GobDecode(buf[:l])
	if err != nil {
		return err
	}
	z.SetScale(scale(buf[l : l+scaleSize]))
	return nil
}
695797
func base64URLDecode(data string) ([]byte, error) {
	var missing = (4 - len(data)%4) % 4
	data += strings.Repeat("=", missing)
	return base64.URLEncoding.DecodeString(data)
}
1366632
func (c *ConfigTree) GobEncode() ([]byte, error) {
	//todo throw an error if not frozen
	w := new(bytes.Buffer)
	encoder := gob.NewEncoder(w)
	if c.root == nil {
		c.root = &node{}
		// c.root.setKeys([]string{})
	}
	if err := encoder.Encode(c.root); err != nil {
		return nil, err
	}
	return w.Bytes(), nil
}
787650
func (s *StableBloomFilter) GobEncode() ([]byte, error) {
	var buf bytes.Buffer
	_, err := s.WriteTo(&buf)
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
1095297
func (ns *Namespace) Base64Decode(content interface{}) (string, error) {
	conv, err := cast.ToStringE(content)
	if err != nil {
		return "", err
	}

	dec, err := base64.StdEncoding.DecodeString(conv)
	return string(dec), err
}
553849
func FindDecode(data []byte, path string, into interface{}) error {
	d, err := Find(data, path)
	if err != nil {
		return err
	}
	return json.Unmarshal(d, into)
}
868156
func GobDecodeEntry(b []byte) (entry Entry, err error) {
	dec := gob.NewDecoder(bytes.NewBuffer(b))
	err = dec.Decode(&entry)
	return
}
504685
func (b *BloomFilter) GobEncode() ([]byte, error) {
	var buf bytes.Buffer
	_, err := b.WriteTo(&buf)
	if err != nil {
		return nil, err
	}

	return buf.Bytes(), nil
}
1006220
func (p *perceptron) GobEncode() ([]byte, error) {
	var buf bytes.Buffer
	encoder := gob.NewEncoder(&buf)

	// if err := encoder.Encode(&p.weights); err != nil {
	// 	return nil, err
	// }

	if err := encoder.Encode(&p.weightsSF); err != nil {
		return nil, err
	}
	if err := encoder.Encode(&p.weightsTF); err != nil {
		return nil, err
	}

	if err := encoder.Encode(&p.totals); err != nil {
		return nil, err
	}

	if err := encoder.Encode(&p.steps); err != nil {
		return nil, err
	}

	if err := encoder.Encode(p.instancesSeen); err != nil {
		return nil, err
	}

	return buf.Bytes(), nil
}
135360
func NewDecoderBytes(in []byte, h Handle) *Decoder {
	d := newDecoder(h)
	d.ResetBytes(in)
	return d
}
962250
func (h *HyperLogLog) GobEncode() ([]byte, error) {
	buf := bytes.Buffer{}
	enc := gob.NewEncoder(&buf)
	if err := enc.Encode(h.reg); err != nil {
		return nil, err
	}
	if err := enc.Encode(h.m); err != nil {
		return nil, err
	}
	if err := enc.Encode(h.p); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
511124
func (pl *Payload) DecodeBinary(dec *gob.Decoder) error {
	return dec.Decode(pl)
}
45463
func encode(data interface{}) ([]byte, error) {
	if data == nil {
		return nil, nil
	}
	buf := bytes.NewBuffer([]byte{})
	enc := gob.NewEncoder(buf)
	if err := enc.Encode(data); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
600904
func GobDecode(b []byte) (store Store, err error) {
	dec := gob.NewDecoder(bytes.NewBuffer(b))
	// no reference because of:
	// gob: decoding into local type *memstore.Store, received remote type Entry
	err = dec.Decode(&store)
	return
}
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) })
}
941260
func (info *ImageInfoType) GobDecode(buf []byte) (err error) {
	fields := []interface{}{&info.data, &info.smask, &info.n, &info.w, &info.h,
		&info.cs, &info.pal, &info.bpc, &info.f, &info.dp, &info.trns, &info.scale, &info.dpi}
	r := bytes.NewBuffer(buf)
	decoder := gob.NewDecoder(r)
	for j := 0; j < len(fields) && err == nil; j++ {
		err = decoder.Decode(fields[j])
	}

	info.i, err = generateImageID(info)
	return
}
225617
func (f *Filter) GobDecode(p []byte) (err error) {
	var gf gobFilter
	buf := bytes.NewReader(p)
	err = gob.NewDecoder(buf).Decode(&gf)
	if err != nil {
		return
	}

	if gf.Hash == nil {
		err = errors.New("no hash function specified")
		return
	}

	//create the hashes from the seeds
	f.hs = make([]sHash, 0, len(gf.Seeds))
	for _, s := range gf.Seeds {
		f.hs = append(f.hs, sHash{
			Ha:   gf.Hash,
			Seed: s,
		})
	}

	//set the other fields
	f.bh = gf.Hash
	f.fs = gf.Filters
	return
}