MCPcopy
hub / github.com/canopy-network/canopy / FromAny

Function FromAny

lib/util.go:524–534  ·  view source on GitHub ↗

FromAny() converts an anypb.Any type back into a proto.Message

(any *anypb.Any)

Source from the content-addressed store, hash-verified

522
523// FromAny() converts an anypb.Any type back into a proto.Message
524func FromAny(any *anypb.Any) (proto.Message, ErrorI) {
525 // convert the proto any into a proto message
526 msg, err := anypb.UnmarshalNew(any, proto.UnmarshalOptions{})
527 // if an error occurred during the conversion
528 if err != nil {
529 // exit with error
530 return nil, ErrFromAny(err)
531 }
532 // exit with the proto message
533 return msg, nil
534}
535
536// BytesToString() converts a byte slice to a hexadecimal string
537func BytesToString(b []byte) string {

Callers 10

MarshalJSONMethod · 0.92
messageFromTxJSONFunction · 0.92
CheckMessageMethod · 0.92
msgToSendFunction · 0.92
TestAnyPbFunction · 0.70
MarshalAnypbJSONFunction · 0.70

Calls 1

ErrFromAnyFunction · 0.70

Tested by 2

TestAnyPbFunction · 0.56