// GobEncode implements gob.GobEncoder interface.
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
}
848678
func GobEncode(store Store, w io.Writer) error {
	enc := gob.NewEncoder(w)
	err := enc.Encode(store)
	return err
}
631156
func (f *Filter) GobEncode() (p []byte, err error) {
	if f.bh == nil {
		err = errors.New("no hash function specified")
	}

	gf := gobFilter{
		Hash:    f.bh,
		Filters: f.fs,
		Seeds:   make([][]byte, 0, len(f.hs)),
	}
	for _, sh := range f.hs {
		gf.Seeds = append(gf.Seeds, sh.Seed)
	}
	var buf bytes.Buffer
	err = gob.NewEncoder(&buf).Encode(gf)
	if err == nil {
		p = buf.Bytes()
	}
	return
}
1073569
func (pl *Payload) Encode() ([]byte, error) {
	// Note that this method can't be named MarshalBinary, because the gob encoder would call
	// this method, resulting in infinite recursion.
	var buf bytes.Buffer
	if err := pl.WriteBinary(&buf); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
1257393
func (s *Shape) GoCode() string {
	w := &bytes.Buffer{}

	switch {
	case s.EventStreamAPI != nil:
		if err := renderEventStreamAPIShape(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"failed to generate eventstream API shape, %s, %v",
					s.ShapeName, err),
			)
		}
	case s.Type == "structure":
		if err := structShapeTmpl.Execute(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"Failed to generate struct shape %s, %v",
					s.ShapeName, err),
			)
		}
	case s.IsEnum():
		if err := enumShapeTmpl.Execute(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"Failed to generate enum shape %s, %v",
					s.ShapeName, err),
			)
		}
	default:
		panic(fmt.Sprintln("Cannot generate toplevel shape for", s.Type))
	}

	return w.String()
}
1224832
func (i *InverseBloomFilter) GobEncode() ([]byte, error) {
	var buf bytes.Buffer
	_, err := i.WriteTo(&buf)
	if err != nil {
		return nil, err
	}

	return buf.Bytes(), nil
}
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
}
1272739
func (e *Error) GobDecode(data []byte) error {
	buf := bytes.NewBuffer(data)
	dec := gob.NewDecoder(buf)
	var msg messageType
	err := dec.Decode(&msg)
	if err != nil {
		return err
	}
	switch msg {
	case ErrorLocal:
		var er *Error
		err := dec.Decode(&er)
		if err != nil {
			return err
		}
		e.err = er
	case ErrorGo:
		var er GoError
		err := dec.Decode(&er)
		if err != nil {
			return err
		}
		e.err = er
	default:
		return errors.New("protocol error")
	}
	err = dec.Decode(&e.args)
	if err != nil {
		return err
	}
	err = dec.Decode(&e.pkg)
	if err != nil {
		return err
	}
	err = dec.Decode(&e.file)
	if err != nil {
		return err
	}
	err = dec.Decode(&e.line)
	if err != nil {
		return err
	}
	err = dec.Decode(&e.debugInfo)
	if err != nil {
		return err
	}
	err = dec.Decode(&msg)
	if err != nil {
		return err
	}
	switch msg {
	case NextIsNill:
		return nil
	case Next:
		err = dec.Decode(&e.next)
		if err != nil {
			return err
		}
	default:
		return errors.New("protocol error")
	}
	return nil
}
949249
func (ex Example) GoCode() string {
	var buf bytes.Buffer
	m := exampleFuncMap
	if fMap, ok := exampleCustomizations[ex.API.PackageName()]; ok {
		m = fMap
	}
	tmpl := exampleTmpls.Funcs(m)
	if err := tmpl.ExecuteTemplate(&buf, "example", &ex); err != nil {
		panic(err)
	}

	return strings.TrimSpace(buf.String())
}
958152
func Encode(buf []byte, code uint64) ([]byte, error) {

	if !ValidCode(code) {
		return nil, ErrUnknownCode
	}

	start := make([]byte, 2*binary.MaxVarintLen64, 2*binary.MaxVarintLen64+len(buf))
	spot := start
	n := binary.PutUvarint(spot, code)
	spot = start[n:]
	n += binary.PutUvarint(spot, uint64(len(buf)))

	return append(start[:n], buf...), nil
}
328542
func (encoder *IntLengthFieldBasedEncoder) Encode(data interface{}, out *ByteBuf) error {
	buf := NewByteBuf(32)

	if encoder.prepare != nil {
		err := encoder.prepare(data, out)
		if err != nil {
			return err
		}
	}

	err := encoder.base.Encode(data, buf)
	if err != nil {
		return err
	}

	out.WriteInt(buf.Readable())
	out.WriteByteBuf(buf)
	return nil
}
236511
func GobSerialize(store Store) ([]byte, error) {
	w := new(bytes.Buffer)
	err := GobEncode(store, w)
	return w.Bytes(), err
}
505536
func encode(b []byte) []byte {
	var buf bytes.Buffer
	mw := meta.NewWriter(&buf)
	mw.FinalMode = meta.FinalMeta
	if _, err := io.Copy(mw, bytes.NewReader(b)); err != nil {
		log.Fatal(err)
	}
	if err := mw.Close(); err != nil {
		log.Fatal(err)
	}
	return buf.Bytes()
}
1209429
func (msg *MsgAlert) BtcEncode(w io.Writer, pver uint32, enc MessageEncoding) error {
	var err error
	var serializedpayload []byte
	if msg.Payload != nil {
		// try to Serialize Payload if possible
		r := new(bytes.Buffer)
		err = msg.Payload.Serialize(r, pver)
		if err != nil {
			// Serialize failed - ignore & fallback
			// to SerializedPayload
			serializedpayload = msg.SerializedPayload
		} else {
			serializedpayload = r.Bytes()
		}
	} else {
		serializedpayload = msg.SerializedPayload
	}
	slen := uint64(len(serializedpayload))
	if slen == 0 {
		return messageError("MsgAlert.BtcEncode", "empty serialized payload")
	}
	err = WriteVarBytes(w, pver, serializedpayload)
	if err != nil {
		return err
	}
	return WriteVarBytes(w, pver, msg.Signature)
}
238691
func (w *Waiter) GoCode() string {
	var buf bytes.Buffer
	if err := waiterTmpls.ExecuteTemplate(&buf, "waiter", w); err != nil {
		panic(err)
	}

	return buf.String()
}
1274199
func (b *BoolRule) GobEncode() ([]byte, error) {
	w := new(bytes.Buffer)
	encoder := gob.NewEncoder(w)
	if err := encoder.Encode(b.key); err != nil {
		return nil, err
	}
	if err := encoder.Encode(b.required); err != nil {
		return nil, err
	}
	if b.default_ == nil {
		encoder.Encode(false)
	} else {
		encoder.Encode(true)
		if err := encoder.Encode(&b.default_); err != nil {
			return nil, err
		}
	}
	return w.Bytes(), nil
}
356606
func (o *Operation) GoCode() string {
	var buf bytes.Buffer

	if len(o.OutputRef.Shape.EventStreamsMemberName) != 0 {
		o.API.AddSDKImport("aws/client")
		o.API.AddSDKImport("private/protocol")
		o.API.AddSDKImport("private/protocol/rest")
		o.API.AddSDKImport("private/protocol", o.API.ProtocolPackage())
	}

	if o.API.EndpointDiscoveryOp != nil {
		o.API.AddSDKImport("aws/crr")
		o.API.AddImport("time")
		o.API.AddImport("net/url")
	}

	if o.Endpoint != nil && len(o.Endpoint.HostPrefix) != 0 {
		setupEndpointHostPrefix(o)
	}

	err := operationTmpl.Execute(&buf, o)
	if err != nil {
		panic(err)
	}

	return strings.TrimSpace(buf.String())
}