Debian Codegraph @

pdata/pprofile/pb.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package pprofile // import "go.opentelemetry.io/collector/pdata/pprofile"
5
6 var _ MarshalSizer = (*ProtoMarshaler)(nil)
7
8 type ProtoMarshaler struct{}
9
10 func (e *ProtoMarshaler) MarshalProfiles(pd Profiles) ([]byte, error) {
11 size := pd.getOrig().SizeProto()
12 buf := make([]byte, size)
13 _ = pd.getOrig().MarshalProto(buf)
14 return buf, nil
15 }
16
17 func (e *ProtoMarshaler) ProfilesSize(pd Profiles) int {
18 return pd.getOrig().SizeProto()
19 }
20
21 func (e *ProtoMarshaler) ResourceProfilesSize(pd ResourceProfiles) int {
22 return pd.orig.SizeProto()
23 }
24
25 func (e *ProtoMarshaler) ScopeProfilesSize(pd ScopeProfiles) int {
26 return pd.orig.SizeProto()
27 }
28
29 func (e *ProtoMarshaler) ProfileSize(pd Profile) int {
30 return pd.orig.SizeProto()
31 }
32
33 type ProtoUnmarshaler struct{}
34
35 func (d *ProtoUnmarshaler) UnmarshalProfiles(buf []byte) (Profiles, error) {
36 pd := NewProfiles()
37 err := pd.getOrig().UnmarshalProto(buf)
38 if err != nil {
39 return Profiles{}, err
40 }
41 return pd, nil
42 }