rlp: add RawValue

This commit is contained in:
Felix Lange
2015-09-09 03:34:15 +02:00
parent bc17dba8fb
commit 24bb68e7cf
5 changed files with 39 additions and 1 deletions

View File

@@ -354,6 +354,8 @@ var (
func makeWriter(typ reflect.Type) (writer, error) {
kind := typ.Kind()
switch {
case typ == rawValueType:
return writeRawValue, nil
case typ.Implements(encoderInterface):
return writeEncoder, nil
case kind != reflect.Ptr && reflect.PtrTo(typ).Implements(encoderInterface):
@@ -389,6 +391,11 @@ func isByte(typ reflect.Type) bool {
return typ.Kind() == reflect.Uint8 && !typ.Implements(encoderInterface)
}
func writeRawValue(val reflect.Value, w *encbuf) error {
w.str = append(w.str, val.Bytes()...)
return nil
}
func writeUint(val reflect.Value, w *encbuf) error {
i := val.Uint()
if i == 0 {