neoneo-go/pkg/io/serializable.go
Evgenii Stratonikov f01fc1cc29 io: optimize BinWriter.WriteArray()
Replace reflect.MethodByName with a simple interface cast.
2019-12-09 14:59:49 +03:00

20 lines
628 B
Go

package io
// Serializable defines the binary encoding/decoding interface. Errors are
// returned via BinReader/BinWriter Err field. These functions must have safe
// behavior when passed BinReader/BinWriter with Err already set. Invocations
// to these functions tend to be nested, with this mechanism only the top-level
// caller should handle the error once and all the other code should just not
// panic in presence of error.
type Serializable interface {
DecodeBinary(*BinReader)
EncodeBinary(*BinWriter)
}
type decodable interface {
DecodeBinary(*BinReader)
}
type encodable interface {
EncodeBinary(*BinWriter)
}