runtime/protoiface: remove IsInitializedOutputFlags and IsInitialized
The IsInitialized flag is unused and unnecessary as the error returned
inherently reports whether a message is uninitialized if it is non-nil.
Also cleanup the documentation in protoiface of stale references.
Change-Id: Id75772f4f75f8d7a2a9fbe772d57f7d69ae9fb9d
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220337
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/reflect/protoreflect/methods.go b/reflect/protoreflect/methods.go
index d897ace..57fc014 100644
--- a/reflect/protoreflect/methods.go
+++ b/reflect/protoreflect/methods.go
@@ -21,8 +21,8 @@
Size func(sizeInput) sizeOutput
Marshal func(marshalInput) (marshalOutput, error)
Unmarshal func(unmarshalInput) (unmarshalOutput, error)
- IsInitialized func(isInitializedInput) (isInitializedOutput, error)
Merge func(mergeInput) mergeOutput
+ IsInitialized func(isInitializedInput) (isInitializedOutput, error)
}
supportFlags = uint64
sizeInput = struct {
@@ -58,14 +58,6 @@
pragma.NoUnkeyedLiterals
Flags uint8
}
- isInitializedInput = struct {
- pragma.NoUnkeyedLiterals
- Message Message
- }
- isInitializedOutput = struct {
- pragma.NoUnkeyedLiterals
- Flags uint8
- }
mergeInput = struct {
pragma.NoUnkeyedLiterals
Source Message
@@ -75,4 +67,11 @@
pragma.NoUnkeyedLiterals
Flags uint8
}
+ isInitializedInput = struct {
+ pragma.NoUnkeyedLiterals
+ Message Message
+ }
+ isInitializedOutput = struct {
+ pragma.NoUnkeyedLiterals
+ }
)
diff --git a/runtime/protoiface/methods.go b/runtime/protoiface/methods.go
index f8efd86..1a0baa7 100644
--- a/runtime/protoiface/methods.go
+++ b/runtime/protoiface/methods.go
@@ -21,24 +21,24 @@
// Flags indicate support for optional features.
Flags SupportFlags
- // Size returns the size in bytes of the wire-format encoding of m.
+ // Size returns the size in bytes of the wire-format encoding of a message.
// Marshal must be provided if a custom Size is provided.
- Size func(SizeInput) SizeOutput
+ Size func(in SizeInput) SizeOutput
- // Marshal writes the wire-format encoding of m to the provided buffer.
+ // Marshal formats a message in the wire-format encoding to the provided buffer.
// Size should be provided if a custom Marshal is provided.
// It must not return an error for a partial message.
Marshal func(MarshalInput) (MarshalOutput, error)
- // Unmarshal parses the wire-format encoding of a message and merges the result to m.
+ // Unmarshal parses the wire-format encoding and merges the result into a message.
// It must not reset the target message or return an error for a partial message.
Unmarshal func(UnmarshalInput) (UnmarshalOutput, error)
- // IsInitialized returns an error if any required fields in m are not set.
- IsInitialized func(IsInitializedInput) (IsInitializedOutput, error)
-
- // Merge merges src into dst.
+ // Merge merges the contents of a source message into a destination message.
Merge func(MergeInput) MergeOutput
+
+ // IsInitialized returns an error if any required fields in the message are not set.
+ IsInitialized func(IsInitializedInput) (IsInitializedOutput, error)
}
// SupportFlags indicate support for optional features.
@@ -125,33 +125,11 @@
const (
// UnmarshalInitialized may be set on return if all required fields are known to be set.
- // A value of false does not indicate that the message is uninitialized, only
- // that its status could not be confirmed.
+ // If unset, then it does not necessarily indicate that the message is uninitialized,
+ // only that its status could not be confirmed.
UnmarshalInitialized UnmarshalOutputFlags = 1 << iota
)
-// IsInitializedInput is input to the IsInitialized method.
-type IsInitializedInput = struct {
- pragma.NoUnkeyedLiterals
-
- Message protoreflect.Message
-}
-
-// IsInitializedOutput is output from the IsInitialized method.
-type IsInitializedOutput = struct {
- pragma.NoUnkeyedLiterals
-
- Flags IsInitializedOutputFlags
-}
-
-// IsInitializedOutputFlags are output from the IsInitialized method.
-type IsInitializedOutputFlags = uint8
-
-const (
- // IsInitialized reports whether the message is initialized.
- IsInitialized IsInitializedOutputFlags = 1 << iota
-)
-
// MergeInput is input to the Merge method.
type MergeInput = struct {
pragma.NoUnkeyedLiterals
@@ -175,3 +153,15 @@
// If unset, the merger must have made no changes to the destination.
MergeComplete MergeOutputFlags = 1 << iota
)
+
+// IsInitializedInput is input to the IsInitialized method.
+type IsInitializedInput = struct {
+ pragma.NoUnkeyedLiterals
+
+ Message protoreflect.Message
+}
+
+// IsInitializedOutput is output from the IsInitialized method.
+type IsInitializedOutput = struct {
+ pragma.NoUnkeyedLiterals
+}