aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/google.golang.org/protobuf/protoadapt/convert.go
blob: ce172386bf236f58808d1e419e577f3c72f86d6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package protoadapt bridges the original and new proto APIs.
package protoadapt

import (
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/runtime/protoiface"
	"google.golang.org/protobuf/runtime/protoimpl"
)

// MessageV1 is the original "github.com/golang/protobuf/proto".Message type.
type MessageV1 = protoiface.MessageV1

// MessageV2 is the Message type used by the current google.golang.org/protobuf
// module, adding support for reflection.
type MessageV2 = proto.Message

// MessageV1Of converts a v2 message to a v1 message.
// It returns nil if m is nil.
func MessageV1Of(m MessageV2) protoiface.MessageV1 {
	return protoimpl.X.ProtoMessageV1Of(m)
}

// MessageV2Of converts a v1 message to a v2 message.
// It returns nil if m is nil.
func MessageV2Of(m MessageV1) proto.Message {
	return protoimpl.X.ProtoMessageV2Of(m)
}