func (ms *MessageSet) Equal(other MessageSet) bool {
	return bytes.Equal(ms.buf, other.buf)
}
Equal returns whether other MessageSet is equal to ms.
package message
import (
	"bytes"
	"encoding/binary"
	"errors"
	"fmt"
	"io"
)
var (
	ErrNoMessages = errors.New("no messages provided")
)
type MessageSet struct{ buf []byte }
func NewMessageSet(offset uint64, codec Codec, msgs ...Message) (*MessageSet, error) {
	ms := &MessageSet{buf: make([]byte, SizeOf(msgs...))}
	if ms.Size() == 0 {
		return nil, ErrNoMessages
	}
	ms.set(offset, codec, msgs...)
	if err := ms.compress(offset, codec); err != nil {
		return nil, err
	}
	return ms, nil
}
func SizeOf(msgs ...Message) (size uint32) {
	for i := range msgs {
		if msgs[i] == nil {
			continue
		}
		size += MsgOverhead + msgs[i].Size()
	}
	return
}
func (ms *MessageSet) Iterator() Iterator {
	var pos uint32
	return IteratorFunc(func(lv Level) (*MessageOffset, error) {
		if pos >= ms.Size()-MsgOverhead {
			return nil, io.EOF
		}
		msg := &MessageOffset{
			Pos:     pos,
			Offset:  binary.BigEndian.Uint64(ms.buf[pos : pos+msgOffsetSize]),
			MsgSize: binary.BigEndian.Uint32(ms.buf[pos+msgOffsetSize:]),
		}
		if lv == Full {
			msg.Message = Message(ms.buf[pos+MsgOverhead : pos+MsgOverhead+msg.MsgSize])
		}
		pos += msg.Size()
		return msg, nil
	})
}
func (ms *MessageSet) Size() uint32 {
	return uint32(len(ms.buf))
}