// Encode serializes the target DeleteSession message into the passed io.Writer
// observing the specified protocol version.
//
// This is part of the wtwire.Message interface.
1582
func (m *DeleteSession) Encode(w io.Writer, pver uint32) error {
	return nil
}
864944
func (codec *SyncCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(*notifyRaw); ok {
		out.WriteByte(cmdNotifyRaw)
		out.WriteByteBuf(msg.buf)
		releaseNotifyRaw(msg)
		return nil
	} else if msg, ok := data.(*notify); ok {
		out.WriteByte(cmdNotify)
		out.WriteUint64(msg.offset)
		releaseNotify(msg)
		return nil
	} else if msg, ok := data.(*notifySync); ok {
		out.WriteByte(cmdNotifySync)
		out.WriteUint64(msg.offset)
		releaseNotifySync(msg)
		return nil
	} else if msg, ok := data.(*notifySyncRsp); ok {
		out.WriteByte(cmdNotifySyncRsp)
		out.WriteUint64(msg.offset)
		out.WriteByte(msg.count)
		out.WriteByteBuf(msg.buf)
		releaseNotifySyncRsp(msg)
		return nil
	} else if msg, ok := data.(*notifyHB); ok {
		out.WriteByte(cmdNotifyHB)
		out.WriteUint64(msg.offset)
		return nil
	}

	return fmt.Errorf("not support msg: %v", data)
}
1243970
func (m *DeleteSession) Decode(r io.Reader, pver uint32) error {
	return nil
}
607303
func (encoder *HTTPEncoder) Encode(v interface{}, resp io.Writer, accept string) error {
	now := time.Now()
	if accept == "" {
		accept = "*/*"
	}
	var contentType string
	for _, t := range encoder.contentTypes {
		if accept == "*/*" || accept == t {
			contentType = accept
			break
		}
	}
	defer MeasureSince([]string{"goa", "encode", contentType}, now)
	p := encoder.pools[contentType]
	if p == nil && contentType != "*/*" {
		p = encoder.pools["*/*"]
	}
	if p == nil {
		return fmt.Errorf("No encoder registered for %s and no default encoder", contentType)
	}

	// the encoderPool will handle whether or not a pool is actually in use
	e := p.Get(resp)
	if err := e.Encode(v); err != nil {
		return err
	}
	p.Put(e)

	return nil
}
476301
func (m *Marshaller) Encode(obj interface{}, w io.Writer) error {
	m.writer.w = w
	err := m.marshal.Marshal(obj)
	m.writer.w = nil
	return err
}
704055
func (e *Encoder) Encode(v interface{}) error {
	f, ok := v.(marshalerFaster)
	if ok {
		e.buf.Reset()
		err := f.MarshalJSONBuf(&e.buf)
		if err != nil {
			return err
		}

		_, err = io.Copy(e.w, &e.buf)
		return err
	}

	return e.enc.Encode(v)
}
1195118
func (c *CipherSeed) encode(w io.Writer) error {
	err := binary.Write(w, binary.BigEndian, c.InternalVersion)
	if err != nil {
		return err
	}

	if err := binary.Write(w, binary.BigEndian, c.Birthday); err != nil {
		return err
	}

	if _, err := w.Write(c.Entropy[:]); err != nil {
		return err
	}

	return nil
}
90055
func (e *Encoder) Encode(event *watch.Event) error {
	data, err := runtime.Encode(e.embeddedEncoder, event.Object)
	if err != nil {
		return err
	}
	// FIXME: get rid of json.RawMessage.
	return e.encoder.Encode(&metav1.WatchEvent{
		Type:   string(event.Type),
		Object: runtime.RawExtension{Raw: json.RawMessage(data)},
	})
}
786564
func (e *Event) Encode() []byte {
	buff := bytes.NewBuffer(nil)
	buff.Write(EncodeVarint(e.TimeDelta))

	// msg type and chan are stored together
	msgData := []byte{(e.MsgType << 4) | e.MsgChan}
	if e.MsgType == EventByteMap["Meta"] {
		msgData = []byte{0xFF}
	}
	buff.Write(msgData)
	switch e.MsgType {
	// unknown but found in the wild (seems to come with 1 data bytes)
	case 0x2, 0x3, 0x4, 0x5, 0x6:
		buff.Write([]byte{0x0})
	// Note Off/On
	case 0x8, 0x9, 0xA:
		// note
		binary.Write(buff, binary.BigEndian, e.Note)
		// velocity
		binary.Write(buff, binary.BigEndian, e.Velocity)
		// Control Change / Channel Mode
		// This message is sent when a controller value changes.
		// Controllers include devices such as pedals and levers.
		// Controller numbers 120-127 are reserved as "Channel Mode Messages".
		// The controller number is between 0-119.
		// The new controller value is between 0-127.
	case 0xB:
		binary.Write(buff, binary.BigEndian, e.Controller)
		binary.Write(buff, binary.BigEndian, e.NewValue)
		/*
			channel mode messages
			Documented, not technically exposed

			This the same code as the Control Change, but implements Mode control and
			special message by using reserved controller numbers 120-127. The commands are:

			All Sound Off
			c = 120, v = 0
			When All Sound Off is received all oscillators will turn off,
			and their volume envelopes are set to zero as soon as possible.

			Reset All Controllers
			c = 121, v = x
			When Reset All Controllers is received, all controller values are reset to their default values.
			Value must only be zero unless otherwise allowed in a specific Recommended Practice.

			Local Control.
			c = 122, v = 0: Local Control Off
			c = 122, v = 127: Local Control On
			When Local Control is Off, all devices on a given channel will respond only to data received over MIDI.
			Played data, etc. will be ignored. Local Control On restores the functions of the normal controllers.

			All Notes Off.
			c = 123, v = 0: All Notes Off (See text for description of actual mode commands.)
			c = 124, v = 0: Omni Mode Off
			c = 125, v = 0: Omni Mode On
			c = 126, v = M: Mono Mode On (Poly Off) where M is the number of channels (Omni Off) or 0 (Omni On)
			c = 127, v = 0: Poly Mode On (Mono Off) (Note: These four messages also cause All Notes Off)
			When an All Notes Off is received, all oscillators will turn off.
			Program Change
					This message sent when the patch number changes. Value is the new program number.
		*/
	case 0xC:
		binary.Write(buff, binary.BigEndian, e.NewProgram)
		binary.Write(buff, binary.BigEndian, e.NewValue)
		// Channel Pressure (Aftertouch)
		// This message is most often sent by pressing down on the key after it "bottoms out".
		// This message is different from polyphonic after-touch.
		// Use this message to send the single greatest pressure value (of all the current depressed keys).
		// Value is the pressure value.
		// Most MIDI controllers don't generate Polyphonic Key AfterTouch because that requires a pressure sensor for each individual key
		// on a MIDI keyboard, and this is an expensive feature to implement.
		// For this reason, many cheaper units implement Channel Pressure instead of Aftertouch, as the former only requires
		// one sensor for the entire keyboard's pressure.
	case 0xD:
		binary.Write(buff, binary.BigEndian, e.Pressure)
		// Pitch Bend Change.
		// This message is sent to indicate a change in the pitch bender (wheel or lever, typically).
		// The pitch bender is measured by a fourteen bit value. Center (no pitch change) is 2000H.
		// Sensitivity is a function of the transmitter.
		// Last 7 bits of the first byte are the least significant 7 bits.
		// Last 7 bits of the second byte are the most significant 7 bits.
	case 0xE:
		// pitchbend
		lsb := byte(e.AbsPitchBend & 0x7F)
		msb := byte((e.AbsPitchBend & (0x7F << 7)) >> 7)
		binary.Write(buff, binary.BigEndian, []byte{lsb, msb})
		//  Meta
		// All meta-events start with FF followed by the command (xx), the length,
		// or number of bytes that will contain data (nn), and the actual data (dd).
		// meta_event = 0xFF + <meta_type> + <v_length> + <event_data_bytes>
	case 0xF:
		binary.Write(buff, binary.BigEndian, e.Cmd)
		switch e.Cmd {
		// Copyright Notice
		case 0x02:
			copyright := []byte(e.Copyright)
			binary.Write(buff, binary.BigEndian, EncodeVarint(uint32(len(copyright))))
			binary.Write(buff, binary.BigEndian, copyright)
			// BPM / tempo event
		case 0x51:
			binary.Write(buff, binary.BigEndian, EncodeVarint(3))
			binary.Write(buff, binary.BigEndian, Uint24(e.MsPerQuartNote))
		case 0x2f: // end of track
			buff.WriteByte(0x0)
		}
	default:
		fmt.Printf("didn't encode %#v because didn't know how to\n", e)
	}

	return buff.Bytes()
}
495507
func (codec *StringCodec) Encode(data interface{}, out *ByteBuf) error {
	if msg, ok := data.(string); ok {
		return out.WriteString(msg)
	}

	return fmt.Errorf("not string: %+v", data)
}
1017525
func encode(c baseCodec, msg interface{}) ([]byte, error) {
	if msg == nil { // NOTE: typed nils will not be caught by this check
		return nil, nil
	}
	b, err := c.Marshal(msg)
	if err != nil {
		return nil, status.Errorf(codes.Internal, "grpc: error while marshaling: %v", err.Error())
	}
	if uint(len(b)) > math.MaxUint32 {
		return nil, status.Errorf(codes.ResourceExhausted, "grpc: message too large (%d bytes)", len(b))
	}
	return b, nil
}
1319959
func (s *RawSerializer) Encode(obj runtime.Object, w io.Writer) error {
	switch t := obj.(type) {
	case bufferedMarshaller:
		// this path performs a single allocation during write but requires the caller to implement
		// the more efficient Size and MarshalTo methods
		encodedSize := uint64(t.Size())
		data := make([]byte, encodedSize)

		n, err := t.MarshalTo(data)
		if err != nil {
			return err
		}
		_, err = w.Write(data[:n])
		return err

	case proto.Marshaler:
		// this path performs extra allocations
		data, err := t.Marshal()
		if err != nil {
			return err
		}
		_, err = w.Write(data)
		return err

	default:
		return errNotMarshalable{reflect.TypeOf(obj)}
	}
}
1228899
func (todo *Todo) Encode() (*bytes.Buffer, error) {
	b, err := json.Marshal(todo)
	if err != nil {
		return &bytes.Buffer{}, err
	}
	return bytes.NewBuffer(b), nil
}
437289
func (mr *MockPacketEncoderMockRecorder) Encode(typ, data interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encode", reflect.TypeOf((*MockPacketEncoder)(nil).Encode), typ, data)
}
791005
func (f *FailIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error {
	if err := WriteElement(w, f.CltvExpiry); err != nil {
		return err
	}

	return writeOnionErrorChanUpdate(w, &f.Update, pver)
}
761457
func (m *CreateSession) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		m.BlobType,
		m.MaxUpdates,
		m.RewardBase,
		m.RewardRate,
		m.SweepFeeRate,
	)
}
132475
func (enc *WALEncoder) Encode(v *TimedWALMessage) error {
	data := cdc.MustMarshalBinaryBare(v)

	crc := crc32.Checksum(data, crc32c)
	length := uint32(len(data))
	if length > maxMsgSizeBytes {
		return fmt.Errorf("Msg is too big: %d bytes, max: %d bytes", length, maxMsgSizeBytes)
	}
	totalLength := 8 + int(length)

	msg := make([]byte, totalLength)
	binary.BigEndian.PutUint32(msg[0:4], crc)
	binary.BigEndian.PutUint32(msg[4:8], length)
	copy(msg[8:], data)

	_, err := enc.wr.Write(msg)

	return err
}