libs5-go/protocol/base/encodeable_message.go

24 lines
508 B
Go
Raw Normal View History

package base
2024-01-06 11:33:46 +00:00
import "github.com/vmihailenco/msgpack/v5"
var (
_ EncodeableMessage = (*EncodeableMessageImpl)(nil)
)
2024-01-06 11:33:46 +00:00
type EncodeableMessage interface {
ToMessage() (message []byte, err error)
msgpack.CustomEncoder
}
type EncodeableMessageImpl struct {
}
func (e EncodeableMessageImpl) ToMessage() (message []byte, err error) {
return msgpack.Marshal(e)
}
func (e EncodeableMessageImpl) EncodeMsgpack(encoder *msgpack.Encoder) error {
panic("this method should be implemented by the child class")
}