//go:build vtprotobuf
// +build vtprotobuf

// Code generated by protoc-gen-go-vtproto. DO NOT EDIT.
// source: contrib/envoy/extensions/filters/http/sxg/v3alpha/sxg.proto

package v3alpha

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

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 *SXG) 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 *SXG) MarshalToVTStrict(dAtA []byte) (int, error) {
	size := m.SizeVT()
	return m.MarshalToSizedBufferVTStrict(dAtA[:size])
}

func (m *SXG) 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.HeaderPrefixFilters) > 0 {
		for iNdEx := len(m.HeaderPrefixFilters) - 1; iNdEx >= 0; iNdEx-- {
			i -= len(m.HeaderPrefixFilters[iNdEx])
			copy(dAtA[i:], m.HeaderPrefixFilters[iNdEx])
			i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.HeaderPrefixFilters[iNdEx])))
			i--
			dAtA[i] = 0x4a
		}
	}
	if len(m.ShouldEncodeSxgHeader) > 0 {
		i -= len(m.ShouldEncodeSxgHeader)
		copy(dAtA[i:], m.ShouldEncodeSxgHeader)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ShouldEncodeSxgHeader)))
		i--
		dAtA[i] = 0x42
	}
	if len(m.ClientCanAcceptSxgHeader) > 0 {
		i -= len(m.ClientCanAcceptSxgHeader)
		copy(dAtA[i:], m.ClientCanAcceptSxgHeader)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ClientCanAcceptSxgHeader)))
		i--
		dAtA[i] = 0x3a
	}
	if len(m.ValidityUrl) > 0 {
		i -= len(m.ValidityUrl)
		copy(dAtA[i:], m.ValidityUrl)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.ValidityUrl)))
		i--
		dAtA[i] = 0x32
	}
	if len(m.CborUrl) > 0 {
		i -= len(m.CborUrl)
		copy(dAtA[i:], m.CborUrl)
		i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.CborUrl)))
		i--
		dAtA[i] = 0x2a
	}
	if m.MiRecordSize != 0 {
		i = protohelpers.EncodeVarint(dAtA, i, uint64(m.MiRecordSize))
		i--
		dAtA[i] = 0x20
	}
	if m.Duration != nil {
		size, err := (*durationpb.Duration)(m.Duration).MarshalToSizedBufferVTStrict(dAtA[:i])
		if err != nil {
			return 0, err
		}
		i -= size
		i = protohelpers.EncodeVarint(dAtA, i, uint64(size))
		i--
		dAtA[i] = 0x1a
	}
	if m.PrivateKey != nil {
		if vtmsg, ok := interface{}(m.PrivateKey).(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.PrivateKey)
			if err != nil {
				return 0, err
			}
			i -= len(encoded)
			copy(dAtA[i:], encoded)
			i = protohelpers.EncodeVarint(dAtA, i, uint64(len(encoded)))
		}
		i--
		dAtA[i] = 0x12
	}
	if m.Certificate != nil {
		if vtmsg, ok := interface{}(m.Certificate).(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.Certificate)
			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 *SXG) SizeVT() (n int) {
	if m == nil {
		return 0
	}
	var l int
	_ = l
	if m.Certificate != nil {
		if size, ok := interface{}(m.Certificate).(interface {
			SizeVT() int
		}); ok {
			l = size.SizeVT()
		} else {
			l = proto.Size(m.Certificate)
		}
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.PrivateKey != nil {
		if size, ok := interface{}(m.PrivateKey).(interface {
			SizeVT() int
		}); ok {
			l = size.SizeVT()
		} else {
			l = proto.Size(m.PrivateKey)
		}
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.Duration != nil {
		l = (*durationpb.Duration)(m.Duration).SizeVT()
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if m.MiRecordSize != 0 {
		n += 1 + protohelpers.SizeOfVarint(uint64(m.MiRecordSize))
	}
	l = len(m.CborUrl)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	l = len(m.ValidityUrl)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	l = len(m.ClientCanAcceptSxgHeader)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	l = len(m.ShouldEncodeSxgHeader)
	if l > 0 {
		n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
	}
	if len(m.HeaderPrefixFilters) > 0 {
		for _, s := range m.HeaderPrefixFilters {
			l = len(s)
			n += 1 + l + protohelpers.SizeOfVarint(uint64(l))
		}
	}
	n += len(m.unknownFields)
	return n
}
