Skip to content

Commit

Permalink
add a proto message without serialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Apr 14, 2020
1 parent 268651d commit 9d03813
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions codec/proto/message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package proto

type Message struct {
Data []byte
}

func (m *Message) ProtoMessage() {}

func (m *Message) Reset() {
*m = Message{}
}

func (m *Message) String() string {
return string(m.Data)
}

func (m *Message) Marshal() ([]byte, error) {
return m.Data, nil
}

func (m *Message) Unmarshal(data []byte) error {
m.Data = data
return nil
}

func NewMessage(data []byte) *Message {
return &Message{data}
}

0 comments on commit 9d03813

Please sign in to comment.