--- /dev/null
+pkg encoding, type BinaryAppender interface { AppendBinary } #62384
+pkg encoding, type BinaryAppender interface, AppendBinary([]uint8) ([]uint8, error) #62384
+pkg encoding, type TextAppender interface { AppendText } #62384
+pkg encoding, type TextAppender interface, AppendText([]uint8) ([]uint8, error) #62384
--- /dev/null
+Two new interfaces, [TextAppender] and [BinaryAppender], have been
+introduced to append the textual or binary representation of an object
+to a byte slice. These interfaces provide the same functionality as
+[TextMarshaler] and [BinaryMarshaler], but instead of allocating a new slice
+each time, they append the data directly to an existing slice.
UnmarshalBinary(data []byte) error
}
+// BinaryAppender is the interface implemented by an object
+// that can append the binary representation of itself.
+// If a type implements both [BinaryAppender] and [BinaryMarshaler],
+// then v.MarshalBinary() must be semantically identical to v.AppendBinary(nil).
+type BinaryAppender interface {
+ // AppendBinary appends the binary representation of itself to the end of b
+ // (allocating a larger slice if necessary) and returns the updated slice.
+ //
+ // Implementations must not retain b, nor mutate any bytes within b[:len(b)].
+ AppendBinary(b []byte) ([]byte, error)
+}
+
// TextMarshaler is the interface implemented by an object that can
// marshal itself into a textual form.
//
type TextUnmarshaler interface {
UnmarshalText(text []byte) error
}
+
+// TextAppender is the interface implemented by an object
+// that can append the textual representation of itself.
+// If a type implements both [TextAppender] and [TextMarshaler],
+// then v.MarshalText() must be semantically identical to v.AppendText(nil).
+type TextAppender interface {
+ // AppendText appends the textual representation of itself to the end of b
+ // (allocating a larger slice if necessary) and returns the updated slice.
+ //
+ // Implementations must not retain b, nor mutate any bytes within b[:len(b)].
+ AppendText(b []byte) ([]byte, error)
+}