package protodelim

Import Path
	google.golang.org/protobuf/encoding/protodelim (on go.dev)

Dependency Relation
	imports 7 packages, and imported by one package

Involved Source Files Package protodelim marshals and unmarshals varint size-delimited messages.
Package-Level Type Names (total 4)
/* sort by: | */
MarshalOptions is a configurable varint size-delimited marshaler. MarshalOptions proto.MarshalOptions AllowPartial allows messages that have missing required fields to marshal without returning an error. If AllowPartial is false (the default), Marshal will return an error if there are any missing required fields. Deterministic controls whether the same message will always be serialized to the same bytes within the same binary. Setting this option guarantees that repeated serialization of the same message will return the same bytes, and that different processes of the same binary (which may be executing on different machines) will serialize equal messages to the same bytes. It has no effect on the resulting size of the encoded message compared to a non-deterministic marshal. Note that the deterministic serialization is NOT canonical across languages. It is not guaranteed to remain stable over time. It is unstable across different builds with schema changes due to unknown fields. Users who need canonical serialization (e.g., persistent storage in a canonical form, fingerprinting, etc.) must define their own canonicalization specification and implement their own serializer rather than relying on this API. If deterministic serialization is requested, map entries will be sorted by keys in lexographical order. This is an implementation detail and subject to change. MarshalOptions.NoUnkeyedLiterals pragma.NoUnkeyedLiterals UseCachedSize indicates that the result of a previous Size call may be reused. Setting this option asserts that: 1. Size has previously been called on this message with identical options (except for UseCachedSize itself). 2. The message and all its submessages have not changed in any way since the Size call. For lazily decoded messages, accessing a message results in decoding the message, which is a change. If either of these invariants is violated, the results are undefined and may include panics or corrupted output. Implementations MAY take this option into account to provide better performance, but there is no guarantee that they will do so. There is absolutely no guarantee that Size followed by Marshal with UseCachedSize set will perform equivalently to Marshal alone. Marshal returns the wire-format encoding of m. MarshalAppend appends the wire-format encoding of m to b, returning the result. This is a less common entry point than [Marshal], which is only needed if you need to supply your own buffers for performance reasons. MarshalState returns the wire-format encoding of a message. This method permits fine-grained control over the marshaler. Most users should use [Marshal] instead. MarshalTo writes a varint size-delimited wire-format message to w. If w returns an error, MarshalTo returns it unchanged. Size returns the size in bytes of the wire-format encoding of m. Note that Size might return more bytes than Marshal will write in the case of lazily decoded messages that arrive in non-minimal wire format: see https://protobuf.dev/reference/go/size/ for more details.
Reader is the interface expected by [UnmarshalFrom]. It is implemented by *[bufio.Reader]. ( Reader) Read(p []byte) (n int, err error) ( Reader) ReadByte() (byte, error) google.golang.org/grpc/mem.Reader (interface) *bufio.Reader bufio.ReadWriter *bytes.Buffer *bytes.Reader compress/flate.Reader (interface) *github.com/apache/thrift/lib/go/thrift.RichTransport *github.com/apache/thrift/lib/go/thrift.StreamTransport *github.com/apache/thrift/lib/go/thrift.TBufferedTransport *github.com/apache/thrift/lib/go/thrift.TFramedTransport *github.com/apache/thrift/lib/go/thrift.THttpClient github.com/apache/thrift/lib/go/thrift.TMemoryBuffer github.com/apache/thrift/lib/go/thrift.TRichTransport (interface) *github.com/golang/snappy.Reader github.com/klauspost/compress/flate.Reader (interface) *github.com/klauspost/compress/internal/snapref.Reader *github.com/klauspost/compress/s2.Reader github.com/klauspost/compress/s2.ReadSeeker *github.com/libp2p/go-buffer-pool.Buffer github.com/quic-go/quic-go/quicvarint.Reader (interface) *strings.Reader Reader : compress/flate.Reader Reader : github.com/klauspost/compress/flate.Reader Reader : github.com/quic-go/quic-go/quicvarint.Reader Reader : io.ByteReader Reader : io.Reader func UnmarshalFrom(r Reader, m proto.Message) error func UnmarshalOptions.UnmarshalFrom(r Reader, m proto.Message) error
SizeTooLargeError is an error that is returned when the unmarshaler encounters a message size that is larger than its configured [UnmarshalOptions.MaxSize]. MaxSize is the MaxSize limit configured in UnmarshalOptions, which Size exceeded. Size is the varint size of the message encountered that was larger than the provided MaxSize. (*SizeTooLargeError) Error() string *SizeTooLargeError : error
UnmarshalOptions is a configurable varint size-delimited unmarshaler. MaxSize is the maximum size in wire-format bytes of a single message. Unmarshaling a message larger than MaxSize will return an error. A zero MaxSize will default to 4 MiB. Setting MaxSize to -1 disables the limit. UnmarshalOptions proto.UnmarshalOptions AllowPartial accepts input for messages that will result in missing required fields. If AllowPartial is false (the default), Unmarshal will return an error if there are any missing required fields. If DiscardUnknown is set, unknown fields are ignored. Merge merges the input into the destination message. The default behavior is to always reset the message before unmarshaling, unless Merge is specified. NoLazyDecoding turns off lazy decoding, which otherwise is enabled by default. Lazy decoding only affects submessages (annotated with [lazy = true] in the .proto file) within messages that use the Opaque API. UnmarshalOptions.NoUnkeyedLiterals pragma.NoUnkeyedLiterals RecursionLimit limits how deeply messages may be nested. If zero, a default limit is applied. Resolver is used for looking up types when unmarshaling extension fields. If nil, this defaults to using protoregistry.GlobalTypes. Unmarshal parses the wire-format message in b and places the result in m. The provided message must be mutable (e.g., a non-nil pointer to a message). UnmarshalFrom parses and consumes a varint size-delimited wire-format message from r. The provided message must be mutable (e.g., a non-nil pointer to a message). The error is [io.EOF] error only if no bytes are read. If an EOF happens after reading some but not all the bytes, UnmarshalFrom returns a non-io.EOF error. In particular if r returns a non-io.EOF error, UnmarshalFrom returns it unchanged, and if only a size is read with no subsequent message, [io.ErrUnexpectedEOF] is returned. UnmarshalState parses a wire-format message and places the result in m. This method permits fine-grained control over the unmarshaler. Most users should use [Unmarshal] instead.
Package-Level Functions (total 2)
MarshalTo writes a varint size-delimited wire-format message to w with the default options. See the documentation for [MarshalOptions.MarshalTo].
UnmarshalFrom parses and consumes a varint size-delimited wire-format message from r with the default options. The provided message must be mutable (e.g., a non-nil pointer to a message). See the documentation for [UnmarshalOptions.UnmarshalFrom].