codec: fix interface
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
8feab7cc48
commit
e6f870bda7
@ -38,9 +38,9 @@ type MessageType int
|
|||||||
// connection. ReadBody may be called with a nil argument to force the
|
// connection. ReadBody may be called with a nil argument to force the
|
||||||
// body to be read and discarded.
|
// body to be read and discarded.
|
||||||
type Codec interface {
|
type Codec interface {
|
||||||
ReadHeader(io.ReadWriter, *Message, MessageType) error
|
ReadHeader(io.Reader, *Message, MessageType) error
|
||||||
ReadBody(io.ReadWriter, interface{}) error
|
ReadBody(io.Reader, interface{}) error
|
||||||
Write(io.ReadWriter, *Message, interface{}) error
|
Write(io.Writer, *Message, interface{}) error
|
||||||
Marshal(interface{}) ([]byte, error)
|
Marshal(interface{}) ([]byte, error)
|
||||||
Unmarshal([]byte, interface{}) error
|
Unmarshal([]byte, interface{}) error
|
||||||
String() string
|
String() string
|
||||||
|
@ -13,11 +13,11 @@ type Frame struct {
|
|||||||
Data []byte
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *noopCodec) ReadBody(conn io.ReadWriter, b interface{}) error {
|
func (c *noopCodec) ReadBody(conn io.Reader, b interface{}) error {
|
||||||
// read bytes
|
// read bytes
|
||||||
buf, err := ioutil.ReadAll(conn)
|
buf, err := ioutil.ReadAll(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -46,7 +46,7 @@ func (c *noopCodec) ReadBody(conn io.ReadWriter, b interface{}) error {
|
|||||||
return nil
|
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 {
|
if b == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user