mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
25 lines
428 B
Go
25 lines
428 B
Go
package serial
|
|
|
|
import (
|
|
"github.com/golang/protobuf/proto"
|
|
)
|
|
|
|
type AnyResolver interface {
|
|
Resolve(typeURL string) (proto.Message, error)
|
|
}
|
|
|
|
type serialResolver struct {
|
|
}
|
|
|
|
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{}
|
|
}
|