codec: fix interface

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-20 23:53:29 +03:00
parent 8feab7cc48
commit e6f870bda7
2 changed files with 6 additions and 6 deletions

View File

@ -38,9 +38,9 @@ type MessageType int
// connection. ReadBody may be called with a nil argument to force the
// body to be read and discarded.
type Codec interface {
ReadHeader(io.ReadWriter, *Message, MessageType) error
ReadBody(io.ReadWriter, interface{}) error
Write(io.ReadWriter, *Message, interface{}) error
ReadHeader(io.Reader, *Message, MessageType) error
ReadBody(io.Reader, interface{}) error
Write(io.Writer, *Message, interface{}) error
Marshal(interface{}) ([]byte, error)
Unmarshal([]byte, interface{}) error
String() string

View File

@ -13,11 +13,11 @@ type Frame struct {
Data []byte
}
func (c *noopCodec) ReadHeader(conn io.ReadWriter, m *Message, t MessageType) error {
func (c *noopCodec) ReadHeader(conn io.Reader, m *Message, t MessageType) error {
return nil
}
func (c *noopCodec) ReadBody(conn io.ReadWriter, b interface{}) error {
func (c *noopCodec) ReadBody(conn io.Reader, b interface{}) error {
// read bytes
buf, err := ioutil.ReadAll(conn)
if err != nil {
@ -46,7 +46,7 @@ func (c *noopCodec) ReadBody(conn io.ReadWriter, b interface{}) error {
return nil
}
func (c *noopCodec) Write(conn io.ReadWriter, m *Message, b interface{}) error {
func (c *noopCodec) Write(conn io.Writer, m *Message, b interface{}) error {
if b == nil {
return nil
}