예제 #1
0
func (dec *Decoder) decodeBinaryUnmarshaler(v encoding.BinaryUnmarshaler) error {
	data, err := ioutil.ReadAll(dec.r)
	if err != nil {
		return err
	}
	return v.UnmarshalBinary(data)
}
예제 #2
0
func RedisParseBinary(res string, obj encoding.BinaryUnmarshaler, err error) error {
	if err != nil {
		return err
	}
	err = obj.UnmarshalBinary([]byte(res))
	return err
}
예제 #3
0
// DecodeLV reads the length-value record from r and unmarshals it into v.
func DecodeLV(r io.Reader, v encoding.BinaryUnmarshaler) error {
	buf, err := ReadLV(r)
	if err != nil {
		return err
	}

	if err := v.UnmarshalBinary(buf); err != nil {
		return err
	}
	return nil
}
예제 #4
0
func copyBinary(t *testing.T, from encoding.BinaryMarshaler, to encoding.BinaryUnmarshaler) {
	data, err := from.MarshalBinary()
	if err != nil {
		t.Errorf(err.Error())
		return
	}

	err = to.UnmarshalBinary(data)
	if err != nil {
		t.Errorf(err.Error())
		return
	}
}
예제 #5
0
파일: encdec.go 프로젝트: mrkovec/encdec
//  Unmarshaler decodes a encoding.BinaryUnmarshaler from buffer
func (d *Dec) Unmarshaler(x encoding.BinaryUnmarshaler) {
	if d.err != nil {
		return
	}
	if d.i >= len(d.decbuf) || d.i < 0 /*overflow*/ {
		d.err = errNoDecData
		return
	}
	if x == nil {
		d.err = errDecode
		return
	}

	d.err = x.UnmarshalBinary(d.ByteSlice())
}
예제 #6
0
// Get implements KeyValueStore.
func (l *LevelDB) Get(key encoding.BinaryMarshaler, value encoding.BinaryUnmarshaler) (bool, error) {
	k, err := key.MarshalBinary()
	if err != nil {
		return false, err
	}
	raw, err := l.storage.Get(k, l.readOpts)
	if err == leveldb.ErrNotFound {
		return false, nil
	}
	if err != nil {
		return false, err
	}
	if value == nil {
		return true, nil
	}
	return true, value.UnmarshalBinary(raw)
}
예제 #7
0
func (i *levelDBKeyValueAccessor) Value(value encoding.BinaryUnmarshaler) error {
	return value.UnmarshalBinary(i.it.Value())
}
예제 #8
0
func (i *levelDBKeyValueAccessor) Key(key encoding.BinaryUnmarshaler) error {
	return key.UnmarshalBinary(i.it.Key())
}
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
	fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, false, true))
	if fnerr != nil {
		panic(fnerr)
	}
}