1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/common/serial/resolver.go

24 lines
426 B
Go
Raw Normal View History

2021-06-19 10:00:22 -04:00
package serial
import (
"github.com/golang/protobuf/proto"
)
type AnyResolver interface {
Resolve(typeURL string) (proto.Message, error)
}
2021-11-27 01:32:07 -05:00
type serialResolver struct{}
2021-06-19 10:00:22 -04:00
func (s serialResolver) Resolve(typeURL string) (proto.Message, error) {
instance, err := GetInstance(typeURL)
if err != nil {
return nil, err
}
return instance.(proto.Message), nil
}
func GetResolver() AnyResolver {
return &serialResolver{}
}