blob: 1f0d183b102dbbf20cae52c85066e4148377de77 [file] [log] [blame]
khenaidoo7d3c5582021-08-11 18:09:44 -04001// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package proto
6
7import (
8 "google.golang.org/protobuf/internal/errors"
9 "google.golang.org/protobuf/reflect/protoreflect"
10)
11
12// Message is the top-level interface that all messages must implement.
13// It provides access to a reflective view of a message.
14// Any implementation of this interface may be used with all functions in the
15// protobuf module that accept a Message, except where otherwise specified.
16//
17// This is the v2 interface definition for protobuf messages.
18// The v1 interface definition is "github.com/golang/protobuf/proto".Message.
19//
20// To convert a v1 message to a v2 message,
21// use "github.com/golang/protobuf/proto".MessageV2.
22// To convert a v2 message to a v1 message,
23// use "github.com/golang/protobuf/proto".MessageV1.
24type Message = protoreflect.ProtoMessage
25
26// Error matches all errors produced by packages in the protobuf module.
27//
28// That is, errors.Is(err, Error) reports whether an error is produced
29// by this module.
30var Error error
31
32func init() {
33 Error = errors.Error
34}
35
36// MessageName returns the full name of m.
37// If m is nil, it returns an empty string.
38func MessageName(m Message) protoreflect.FullName {
39 if m == nil {
40 return ""
41 }
42 return m.ProtoReflect().Descriptor().FullName()
43}