// MaxDataLen returns the maximum data length
MaxDataLen returns the maximum data length
// MaxDataLen returns the maximum data length
func (f *DatagramFrame) MaxDataLen(maxSize protocol.ByteCount, version protocol.VersionNumber) protocol.ByteCount {
	headerLen := protocol.ByteCount(1)
	if f.DataLenPresent {
		headerLen++
	}
	if headerLen > maxSize {
		return 0
	}
	maxDataLen := maxSize - headerLen
	if f.DataLenPresent && quicvarint.Len(uint64(maxDataLen)) != 1 {
		maxDataLen--
	}
	return maxDataLen
}
func ( f * DatagramFrame ) MaxDataLen ( maxSize protocol . ByteCount , version protocol . VersionNumber ) protocol . ByteCount { headerLen := protocol . ByteCount ( 1 ) if f . DataLenPresent { headerLen ++ } if headerLen > maxSize { return 0 } maxDataLen := maxSize - headerLen if f . DataLenPresent && quicvarint . Len ( uint64 ( maxDataLen ) ) != 1 { maxDataLen -- } return maxDataLen }
MaxDataLen returns the maximum data length
MaxDataLen returns the maximum data length
// pretend that the data size will be 1 bytes // if it turns out that varint encoding the length will consume 2 bytes, we need to adjust the data length afterwards