func (mc *multiCodec) encodeRevision(rev *Revision) (data []byte, err error) {
	return mc.codecFor(mc.latestVersion).encodeRevision(rev)
}
Encodes revision with most recent codec.
package tree
import (
	"bytes"
	"errors"
	"fmt"
	"log"
	"sync"
	"unicode/utf8"
)
type Codec interface {
	encodeNode(src *Node) (data []byte, err error)
	encodeRevision(rev *Revision) (data []byte, err error)
	decodeNode(data []byte, node *Node) (err error)
	decodeRevision(data []byte, rev *Revision) (err error)
}
type multiCodec struct {
	mu            sync.Mutex
	codecs        map[byte]Codec
	latestVersion byte
}
var (
	errNoCodec = errors.New("no codec found")
)
func newMultiCodec() *multiCodec {
	return &multiCodec{
		codecs: make(map[byte]Codec),
	}
}
func (mc *multiCodec) register(version byte, c Codec) {
	mc.mu.Lock()
	mc.codecs[version] = c
	if version > mc.latestVersion {
		mc.latestVersion = version
	}
	mc.mu.Unlock()
}
func (mc *multiCodec) encodeNode(node *Node) (data []byte, err error) {
	return mc.codecFor(mc.latestVersion).encodeNode(node)
}