Due to inconsistencies between how Rust and Go handle types, SCALE sometimes requires custom encoding definitions. It would be quite simple for us to enable types to have a custom encode/decode method defined, while using the standard encode/decode for all types that do not.
For every type we encode/decode, we can use the reflect package to check if a method with the correct name exists:
someType := reflect.TypeOf(interface)
_, ok := someType.MethodByName("EncodeScale")
if ok {
return someType.EncodeScale()
} else {
return Encode(someType)
}
Due to inconsistencies between how Rust and Go handle types, SCALE sometimes requires custom encoding definitions. It would be quite simple for us to enable types to have a custom encode/decode method defined, while using the standard encode/decode for all types that do not.
For every type we encode/decode, we can use the
reflectpackage to check if a method with the correct name exists: