refactor: add directoryReferenceSerializationMap map wrapper to handle DirectoryReference serialization

This commit is contained in:
Derrick Hammer 2024-01-05 06:36:18 -05:00
parent 453e8590c7
commit 00157e463c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 0 deletions

View File

@ -14,9 +14,15 @@ type fileReferenceMap struct {
linkedhashmap.Map linkedhashmap.Map
} }
type directoryReferenceSerializationMap struct {
linkedhashmap.Map
}
type unmarshalNewInstanceFunc func() interface{} type unmarshalNewInstanceFunc func() interface{}
var _ SerializableMetadata = (*directoryReferenceMap)(nil) var _ SerializableMetadata = (*directoryReferenceMap)(nil)
var _ SerializableMetadata = (*fileReferenceMap)(nil)
var _ msgpack.CustomEncoder = (*directoryReferenceSerializationMap)(nil)
func unmarshalMapMsgpack(dec *msgpack.Decoder, m *linkedhashmap.Map, placeholder interface{}, intMap bool) error { func unmarshalMapMsgpack(dec *msgpack.Decoder, m *linkedhashmap.Map, placeholder interface{}, intMap bool) error {
*m = *linkedhashmap.New() *m = *linkedhashmap.New()
@ -170,3 +176,7 @@ func (drm *directoryReferenceMap) UnmarshalJSON(bytes []byte) error {
createDirInstance := func() interface{} { return &DirectoryReference{} } createDirInstance := func() interface{} { return &DirectoryReference{} }
return unmarshalMapJson(bytes, &drm.Map, createDirInstance) return unmarshalMapJson(bytes, &drm.Map, createDirInstance)
} }
func (frm directoryReferenceSerializationMap) EncodeMsgpack(enc *msgpack.Encoder) error {
return marshallMapMsgpack(enc, &frm.Map)
}