2024-01-05 13:58:13 +00:00
|
|
|
package metadata
|
|
|
|
|
2024-03-01 05:18:07 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"github.com/vmihailenco/msgpack/v5"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ msgpack.CustomDecoder = (*MediaMetadataDetails)(nil)
|
|
|
|
_ msgpack.CustomEncoder = (*MediaMetadataDetails)(nil)
|
|
|
|
)
|
|
|
|
|
2024-01-05 13:58:13 +00:00
|
|
|
type MediaMetadataDetails struct {
|
|
|
|
Data map[int]interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMediaMetadataDetails(data map[int]interface{}) *MediaMetadataDetails {
|
|
|
|
return &MediaMetadataDetails{Data: data}
|
|
|
|
}
|
2024-03-01 05:18:07 +00:00
|
|
|
|
|
|
|
func (mmd *MediaMetadataDetails) EncodeMsgpack(enc *msgpack.Encoder) error {
|
|
|
|
return errors.New("Not implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mmd *MediaMetadataDetails) DecodeMsgpack(dec *msgpack.Decoder) error {
|
|
|
|
mapLen, err := dec.DecodeMapLen()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < mapLen; i++ {
|
|
|
|
key, err := dec.DecodeInt8()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
value, err := dec.DecodeInterface()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
mmd.Data[int(key)] = value
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|