本文整理匯總了Golang中encoding.BinaryUnmarshaler類的典型用法代碼示例。如果您正苦於以下問題:Golang BinaryUnmarshaler類的具體用法?Golang BinaryUnmarshaler怎麽用?Golang BinaryUnmarshaler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BinaryUnmarshaler類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: decodeBinaryUnmarshaler
func (dec *Decoder) decodeBinaryUnmarshaler(v encoding.BinaryUnmarshaler) error {
data, err := ioutil.ReadAll(dec.r)
if err != nil {
return err
}
return v.UnmarshalBinary(data)
}
示例2: RedisParseBinary
func RedisParseBinary(res string, obj encoding.BinaryUnmarshaler, err error) error {
if err != nil {
return err
}
err = obj.UnmarshalBinary([]byte(res))
return err
}
示例3: DecodeLV
// 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: copyBinary
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: Value
func (i *levelDBKeyValueAccessor) Value(value encoding.BinaryUnmarshaler) error {
return value.UnmarshalBinary(i.it.Value())
}
示例6: Unmarshaler
// 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())
}
示例7: Get
// 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)
}
示例8: Key
func (i *levelDBKeyValueAccessor) Key(key encoding.BinaryUnmarshaler) error {
return key.UnmarshalBinary(i.it.Key())
}
示例9: DecBinaryUnmarshal
// 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)
}
}