// Decode reads from the byte slice argument. It returns the total number of
// bytes decoded, and whether there have been any errors during the process.
432757
func (up *Unsubscribe) Decode(src []byte) (int, error) {
	total := 0

	// decode header
	hl, _, rl, err := headerDecode(src[total:], UNSUBSCRIBE)
	total += hl
	if err != nil {
		return total, err
	}

	// check buffer length
	if len(src) < total+2 {
		return total, makeError(up.Type(), "insufficient buffer size, expected %d, got %d", total+2, len(src))
	}

	// read packet id
	up.ID = ID(binary.BigEndian.Uint16(src[total:]))
	total += 2

	// check packet id
	if !up.ID.Valid() {
		return total, makeError(up.Type(), "packet id must be grater than zero")
	}

	// prepare counter
	tl := int(rl) - 2

	// reset topics
	up.Topics = up.Topics[:0]

	for tl > 0 {
		// read topic
		t, n, err := readLPString(src[total:], up.Type())
		total += n
		if err != nil {
			return total, err
		}

		// append to list
		up.Topics = append(up.Topics, t)

		// decrement counter
		tl = tl - n - 1
	}

	// check for empty list
	if len(up.Topics) == 0 {
		return total, makeError(up.Type(), "empty topic list")
	}

	return total, nil
}
298189
func (c *Cap) Decode(r io.Reader) error {
	d := &decoder{r: asByteReader(r)}
	c.decode(d)
	return d.err
}
881337
func (d *Decoder) Decode(v interface{}) error {
	var err error
	d.tval, err = LoadReader(d.r)
	if err != nil {
		return err
	}
	return d.unmarshal(v)
}
336970
func (d *Decoder) Decode(v interface{}) (int, error) {
	if v == nil {
		msg := "can't unmarshal to nil interface"
		return 0, unmarshalError("Unmarshal", ErrNilInterface, msg, nil,
			nil)
	}

	vv := reflect.ValueOf(v)
	if vv.Kind() != reflect.Ptr {
		msg := fmt.Sprintf("can't unmarshal to non-pointer '%v' - use "+
			"& operator", vv.Type().String())
		err := unmarshalError("Unmarshal", ErrBadArguments, msg, nil, nil)
		return 0, err
	}
	if vv.IsNil() && !vv.CanSet() {
		msg := fmt.Sprintf("can't unmarshal to unsettable '%v' - use "+
			"& operator", vv.Type().String())
		err := unmarshalError("Unmarshal", ErrNotSettable, msg, nil, nil)
		return 0, err
	}

	return d.decode(vv)
}
868786
func (m *ParamValue) Decode(buf []byte) {
	data := bytes.NewBuffer(buf)
	binary.Read(data, binary.LittleEndian, &m.PARAM_VALUE)
	binary.Read(data, binary.LittleEndian, &m.PARAM_COUNT)
	binary.Read(data, binary.LittleEndian, &m.PARAM_INDEX)
	binary.Read(data, binary.LittleEndian, &m.PARAM_ID)
	binary.Read(data, binary.LittleEndian, &m.PARAM_TYPE)
}
423002
func Decode(src []byte) (body []byte, err error) {
	body = make([]byte, Encoding.DecodedLen(len(src)))
	_, err = Encoding.Decode(body, src)
	return
}
472488
func Decode(reader io.Reader) (*CachedResponseDecoder, error) {
	dec := gob.NewDecoder(reader)
	res := &CachedResponse{}
	if err := dec.Decode(&res); err != nil {
		return nil, err
	}

	return &CachedResponseDecoder{CachedResponse: res}, nil
}
361892
func (u *DefaultDecoder) Decode(data []byte, v interface{}) error {
	return json.Unmarshal(data, v)
}
260572
func (e *Encoding) Decode(dst, src []byte) (int, error) {
	if len(src)%2 == 1 {
		return 0, ErrLength
	}

	for i := 0; i < len(src)/2; i++ {
		a, ok := e.fromHexChar(src[i*2])
		if !ok {
			return 0, InvalidByteError(src[i*2])
		}
		b, ok := e.fromHexChar(src[i*2+1])
		if !ok {
			return 0, InvalidByteError(src[i*2+1])
		}
		dst[i] = (a << 4) | b
	}

	return len(src) / 2, nil
}
1225626
func (enc Encoding) Decode(dst, src []byte) (int, error) {
	data := ensurePadding(string(src))
	if enc.convert {
		data = convertEncoding(data)
	}
	return enc.encoding.Decode(dst, []byte(data))
}
219314
func (codec *StringCodec) Decode(in *ByteBuf) (bool, interface{}, error) {
	value := string(in.GetMarkedRemindData())
	in.MarkedBytesReaded()
	return true, value, nil
}
1125297
func Decode(r io.Reader) (image.Image, error) {
	r, err := NewReader(r)
	if err != nil {
		return nil, err
	}
	return jpeg.Decode(r)
}
1341749
func (c *Error) Decode(r io.Reader, pver uint32) error {
	return ReadElements(r,
		&c.ChanID,
		&c.Data,
	)
}
1130487
func (b binaryEncoderDecoder) Decode(data []byte, v interface{}) error {
	buf := bytes.NewBuffer(data)
	dec := gob.NewDecoder(buf)
	return dec.Decode(v)
}
886302
func (c *Codec) Decode(buffer []byte) (*Chunk, []byte) {
	chk := &Chunk{}
	for ordinal := 0; len(buffer) > 0; ordinal++ {
		col := &column{}
		buffer = c.decodeColumn(buffer, col, ordinal)
		chk.columns = append(chk.columns, col)
	}
	return chk, buffer
}
1110065
func (pr *PagingResult) Decode(v interface{}) (err error) {
	res := Result{
		"data": pr.Data(),
	}
	return res.Decode(v)
}
1331336
func (enc *Encoding) Decode(src []byte) ([]byte, error) {
	if len(src) == 0 {
		return []byte{}, nil
	}
	var zeros []byte
	for i, c := range src {
		if c == enc.alphabet[0] && i < len(src)-1 {
			zeros = append(zeros, '0')
		} else {
			break
		}
	}
	n := new(big.Int)
	var i int64
	for _, c := range src {
		if i = enc.decodeMap[c]; i < 0 {
			return nil, fmt.Errorf("invalid character '%c' in decoding a base58 string \"%s\"", c, src)
		}
		n.Add(n.Mul(n, radix), big.NewInt(i))
	}
	return n.Append(zeros, 10), nil
}