NewAny() converts a proto.Message into an anypb.Any type
(message proto.Message)
| 509 | |
| 510 | // NewAny() converts a proto.Message into an anypb.Any type |
| 511 | func NewAny(message proto.Message) (*anypb.Any, ErrorI) { |
| 512 | // convert the message to a proto any |
| 513 | a, err := anypb.New(message) |
| 514 | // if an error occurred during the conversion |
| 515 | if err != nil { |
| 516 | // exit with error |
| 517 | return nil, ErrToAny(err) |
| 518 | } |
| 519 | // exit with any |
| 520 | return a, nil |
| 521 | } |
| 522 | |
| 523 | // FromAny() converts an anypb.Any type back into a proto.Message |
| 524 | func FromAny(any *anypb.Any) (proto.Message, ErrorI) { |