Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
Adding Message.UnmarshalBinary
Browse files Browse the repository at this point in the history
Fixes #141
  • Loading branch information
marstr authored and vcabbage committed Oct 26, 2018
1 parent 737d254 commit ffd2c04
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ func (m *Message) Modify(deliveryFailed, undeliverableHere bool, messageAnnotati
})
}

// MarshalBinary encodes the message into binary form
// MarshalBinary encodes the message into binary form.
func (m *Message) MarshalBinary() ([]byte, error) {
buf := new(buffer)
err := m.marshal(buf)
Expand Down Expand Up @@ -1879,6 +1879,14 @@ func (m *Message) marshal(wr *buffer) error {
return nil
}

// UnmarshalBinary decodes the message from binary form.
func (m *Message) UnmarshalBinary(data []byte) error {
buf := &buffer{
b: data,
}
return m.unmarshal(buf)
}

func (m *Message) unmarshal(r *buffer) error {
// loop, decoding sections until bytes have been consumed
for r.len() > 0 {
Expand Down

0 comments on commit ffd2c04

Please sign in to comment.