func (c *ChunkRef) EncodeBytes() ([]byte, error) {
	b, err := msgpack.Marshal(c)
	if err != nil {
		return nil, err
	}
	return b, nil
}
EncodeBytes returns a serialized byte slice of the object.
package chunkref
import (
	"cloud.google.com/go/datastore"
	"github.com/google/uuid"
	pb "github.com/googleforgames/open-saves/api"
	"github.com/googleforgames/open-saves/internal/pkg/cache"
	"github.com/googleforgames/open-saves/internal/pkg/metadb/blobref"
	"github.com/googleforgames/open-saves/internal/pkg/metadb/checksums"
	"github.com/googleforgames/open-saves/internal/pkg/metadb/timestamps"
	"github.com/vmihailenco/msgpack/v5"
)
type ChunkRef struct {
	Key uuid.UUID `datastore:"-"`
	BlobRef uuid.UUID `datastore:"-"`
	Number int32
	Size int32
	blobref.Status
	checksums.Checksums `datastore:",flatten"`
	Timestamps timestamps.Timestamps
}
var _ datastore.PropertyLoadSaver = new(ChunkRef)
var _ datastore.KeyLoader = new(ChunkRef)
var _ cache.Cacheable = new(ChunkRef)
func (c *ChunkRef) LoadKey(k *datastore.Key) error {
	if uuidKey, err := uuid.Parse(k.Name); err == nil {
		c.Key = uuidKey
	} else {
		return err
	}
	if k.Parent != nil {
		if uuidParent, err := uuid.Parse(k.Parent.Name); err == nil {
			c.BlobRef = uuidParent
		} else {
			return err
		}
	}
	return nil
}
func (c *ChunkRef) Load(ps []datastore.Property) error {
	return datastore.LoadStruct(c, ps)
}
func (c *ChunkRef) Save() ([]datastore.Property, error) {
	return datastore.SaveStruct(c)
}
func (c *ChunkRef) ObjectPath() string {
	return c.Key.String()
}
func New(blobRef uuid.UUID, number int32) *ChunkRef {
	return &ChunkRef{
		Key:        uuid.New(),
		BlobRef:    blobRef,
		Number:     number,
		Status:     blobref.StatusInitializing,
		Timestamps: timestamps.New(),
	}
}
func CacheKey(u uuid.UUID) string {
	return u.String()
}
func (c ChunkRef) CacheKey() string {
	return CacheKey(c.Key)
}