//go:build vtprotobuf
// +build vtprotobuf

// Code generated by protoc-gen-go-vtproto. DO NOT EDIT.
// source: envoy/config/endpoint/v3/load_report.proto

package endpointv3

import (
	binary "encoding/binary"
	protohelpers "github.com/planetscale/vtprotobuf/protohelpers"
	durationpb "github.com/planetscale/vtprotobuf/types/known/durationpb"
	structpb "github.com/planetscale/vtprotobuf/types/known/structpb"
	proto "google.golang.org/protobuf/proto"
	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
	math "math"
)

const (
	// Verify that this generated code is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
	// Verify that runtime/protoimpl is sufficiently up-to-date.
	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)

func (m *UpstreamLocalityStats) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *UpstreamLocalityStats) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *UpstreamLocalityStats) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if m.ApplicationUtilization != nil {
		size, err := m.ApplicationUtilization.MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x72
	}
	if m.MemUtilization != nil {
		size, err := m.MemUtilization.MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x6a
	}
	if m.CpuUtilization != nil {
		size, err := m.CpuUtilization.MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x62
	}
	if m.TotalFailConnections != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalFailConnections))
		i--
		dAtA[i] = 0x58
	}
	if m.TotalNewConnections != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalNewConnections))
		i--
		dAtA[i] = 0x50
	}
	if m.TotalActiveConnections != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalActiveConnections))
		i--
		dAtA[i] = 0x48
	}
	if m.TotalIssuedRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalIssuedRequests))
		i--
		dAtA[i] = 0x40
	}
	if len(m.UpstreamEndpointStats) > 0 {
		for iNdEx := len(m.UpstreamEndpointStats) - 1; iNdEx >= 0; iNdEx-- {
			size, err := m.UpstreamEndpointStats[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
			i--
			dAtA[i] = 0x3a
		}
	}
	if m.Priority != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Priority))
		i--
		dAtA[i] = 0x30
	}
	if len(m.LoadMetricStats) > 0 {
		for iNdEx := len(m.LoadMetricStats) - 1; iNdEx >= 0; iNdEx-- {
			size, err := m.LoadMetricStats[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
			i--
			dAtA[i] = 0x2a
		}
	}
	if m.TotalErrorRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalErrorRequests))
		i--
		dAtA[i] = 0x20
	}
	if m.TotalRequestsInProgress != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalRequestsInProgress))
		i--
		dAtA[i] = 0x18
	}
	if m.TotalSuccessfulRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalSuccessfulRequests))
		i--
		dAtA[i] = 0x10
	}
	if m.Locality != nil {
		if vtmsg, ok := interface{}(m.Locality).(interface {
			MarshalToSizedBufferVTStrict([]byte) (int, error)
		}); ok {
			size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		} else {
			encoded, err := proto.Marshal(m.Locality)
			if err != nil {
				return 0, err
			}
			i -= len(encoded)
			copy(dAtA[i:], encoded)
			i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded)))
		}
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *UpstreamEndpointStats) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *UpstreamEndpointStats) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *UpstreamEndpointStats) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if m.TotalIssuedRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalIssuedRequests))
		i--
		dAtA[i] = 0x38
	}
	if m.Metadata != nil {
		size, err := (*structpb.Struct)(m.Metadata).MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x32
	}
	if len(m.LoadMetricStats) > 0 {
		for iNdEx := len(m.LoadMetricStats) - 1; iNdEx >= 0; iNdEx-- {
			size, err := m.LoadMetricStats[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
			i--
			dAtA[i] = 0x2a
		}
	}
	if m.TotalErrorRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalErrorRequests))
		i--
		dAtA[i] = 0x20
	}
	if m.TotalRequestsInProgress != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalRequestsInProgress))
		i--
		dAtA[i] = 0x18
	}
	if m.TotalSuccessfulRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalSuccessfulRequests))
		i--
		dAtA[i] = 0x10
	}
	if m.Address != nil {
		if vtmsg, ok := interface{}(m.Address).(interface {
			MarshalToSizedBufferVTStrict([]byte) (int, error)
		}); ok {
			size, err := vtmsg.MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		} else {
			encoded, err := proto.Marshal(m.Address)
			if err != nil {
				return 0, err
			}
			i -= len(encoded)
			copy(dAtA[i:], encoded)
			i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded)))
		}
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *EndpointLoadMetricStats) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *EndpointLoadMetricStats) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *EndpointLoadMetricStats) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if m.TotalMetricValue != 0 {
		i -= 8
		binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.TotalMetricValue))))
		i--
		dAtA[i] = 0x19
	}
	if m.NumRequestsFinishedWithMetric != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumRequestsFinishedWithMetric))
		i--
		dAtA[i] = 0x10
	}
	if len(m.MetricName) > 0 {
		i -= len(m.MetricName)
		copy(dAtA[i:], m.MetricName)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.MetricName)))
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *UnnamedEndpointLoadMetricStats) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *UnnamedEndpointLoadMetricStats) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *UnnamedEndpointLoadMetricStats) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if m.TotalMetricValue != 0 {
		i -= 8
		binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.TotalMetricValue))))
		i--
		dAtA[i] = 0x11
	}
	if m.NumRequestsFinishedWithMetric != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.NumRequestsFinishedWithMetric))
		i--
		dAtA[i] = 0x8
	}
	return len(dAtA) - i, nil
}

func (m *ClusterStats_DroppedRequests) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *ClusterStats_DroppedRequests) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *ClusterStats_DroppedRequests) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if m.DroppedCount != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.DroppedCount))
		i--
		dAtA[i] = 0x10
	}
	if len(m.Category) > 0 {
		i -= len(m.Category)
		copy(dAtA[i:], m.Category)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Category)))
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *ClusterStats) MarshalVTStrict() (dAtA []byte, err error) {
	if m == nil {
		return nil, nil
	}
	size := m.SizeVT()
	dAtA = make([]byte, size)
	n, err := m.MarshalToSizedBufferVTStrict(dAtA[:size])
	if err != nil {
		return nil, err
	}
	return dAtA[:n], nil
}

func (m *ClusterStats) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *ClusterStats) MarshalToSizedBufferVTStrict(dAtA []byte) (int, error) {
	if m == nil {
		return 0, nil
	}
	i := len(dAtA)
	_ = i
	var l int
	_ = l
	if m.unknownFields != nil {
		i -= len(m.unknownFields)
		copy(dAtA[i:], m.unknownFields)
	}
	if len(m.ClusterServiceName) > 0 {
		i -= len(m.ClusterServiceName)
		copy(dAtA[i:], m.ClusterServiceName)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ClusterServiceName)))
		i--
		dAtA[i] = 0x32
	}
	if len(m.DroppedRequests) > 0 {
		for iNdEx := len(m.DroppedRequests) - 1; iNdEx >= 0; iNdEx-- {
			size, err := m.DroppedRequests[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
			i--
			dAtA[i] = 0x2a
		}
	}
	if m.LoadReportInterval != nil {
		size, err := (*durationpb.Duration)(m.LoadReportInterval).MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x22
	}
	if m.TotalDroppedRequests != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.TotalDroppedRequests))
		i--
		dAtA[i] = 0x18
	}
	if len(m.UpstreamLocalityStats) > 0 {
		for iNdEx := len(m.UpstreamLocalityStats) - 1; iNdEx >= 0; iNdEx-- {
			size, err := m.UpstreamLocalityStats[iNdEx].MarshalToSizedBufferVTStrict(dAtA[:i])
			if err != nil {
				return 0, err
			}
			i -= size
			i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
			i--
			dAtA[i] = 0x12
		}
	}
	if len(m.ClusterName) > 0 {
		i -= len(m.ClusterName)
		copy(dAtA[i:], m.ClusterName)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ClusterName)))
		i--
		dAtA[i] = 0xa
	}
	return len(dAtA) - i, nil
}

func (m *UpstreamLocalityStats) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	if m.Locality != nil {
		if size, ok := interface{}(m.Locality).(interface {
			SizeVT() int
		}); ok {
			l = size.SizeVT()
		} else {
			l = proto.Size(m.Locality)
		}
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.TotalSuccessfulRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalSuccessfulRequests))
	}
	if m.TotalRequestsInProgress != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalRequestsInProgress))
	}
	if m.TotalErrorRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalErrorRequests))
	}
	if len(m.LoadMetricStats) > 0 {
		for _, e := range m.LoadMetricStats {
			l = e.SizeVT()
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	if m.Priority != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.Priority))
	}
	if len(m.UpstreamEndpointStats) > 0 {
		for _, e := range m.UpstreamEndpointStats {
			l = e.SizeVT()
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	if m.TotalIssuedRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalIssuedRequests))
	}
	if m.TotalActiveConnections != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalActiveConnections))
	}
	if m.TotalNewConnections != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalNewConnections))
	}
	if m.TotalFailConnections != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalFailConnections))
	}
	if m.CpuUtilization != nil {
		l = m.CpuUtilization.SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.MemUtilization != nil {
		l = m.MemUtilization.SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.ApplicationUtilization != nil {
		l = m.ApplicationUtilization.SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	n += len(m.unknownFields)
	return n
}

func (m *UpstreamEndpointStats) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	if m.Address != nil {
		if size, ok := interface{}(m.Address).(interface {
			SizeVT() int
		}); ok {
			l = size.SizeVT()
		} else {
			l = proto.Size(m.Address)
		}
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.TotalSuccessfulRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalSuccessfulRequests))
	}
	if m.TotalRequestsInProgress != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalRequestsInProgress))
	}
	if m.TotalErrorRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalErrorRequests))
	}
	if len(m.LoadMetricStats) > 0 {
		for _, e := range m.LoadMetricStats {
			l = e.SizeVT()
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	if m.Metadata != nil {
		l = (*structpb.Struct)(m.Metadata).SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.TotalIssuedRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalIssuedRequests))
	}
	n += len(m.unknownFields)
	return n
}

func (m *EndpointLoadMetricStats) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = len(m.MetricName)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.NumRequestsFinishedWithMetric != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.NumRequestsFinishedWithMetric))
	}
	if m.TotalMetricValue != 0 {
		n += 9
	}
	n += len(m.unknownFields)
	return n
}

func (m *UnnamedEndpointLoadMetricStats) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	if m.NumRequestsFinishedWithMetric != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.NumRequestsFinishedWithMetric))
	}
	if m.TotalMetricValue != 0 {
		n += 9
	}
	n += len(m.unknownFields)
	return n
}

func (m *ClusterStats_DroppedRequests) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = len(m.Category)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.DroppedCount != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.DroppedCount))
	}
	n += len(m.unknownFields)
	return n
}

func (m *ClusterStats) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	l = len(m.ClusterName)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if len(m.UpstreamLocalityStats) > 0 {
		for _, e := range m.UpstreamLocalityStats {
			l = e.SizeVT()
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	if m.TotalDroppedRequests != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.TotalDroppedRequests))
	}
	if m.LoadReportInterval != nil {
		l = (*durationpb.Duration)(m.LoadReportInterval).SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if len(m.DroppedRequests) > 0 {
		for _, e := range m.DroppedRequests {
			l = e.SizeVT()
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	l = len(m.ClusterServiceName)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	n += len(m.unknownFields)
	return n
}
